Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Lightweight Swift wrapper around libmosquitto client library.

License

NotificationsYou must be signed in to change notification settings

S2Ler/SMosquitto

Repository files navigation

Swift 5.0, macOS, Linux.

A thin Swift wrapper forlibmosquitto. Supports macOS and Linux.

Installation

UseSPM.

SamplePackage.swift

// swift-tools-version:5.0import PackageDescriptionletpackage=Package(  name:"ProjectName",  products:[.executable(name:"ProjectName", targets:["ProjectName"]),],  dependencies:[.package(url:"https://github.com/diejmon/SMosquitto.git",.upToNextMinor(from:"1.4.0")),],  targets:[.target(      name:"ProjectName",      dependencies:["SMosquitto"]),],  swiftLanguageVersions:[.v5])

Usage

import SMosquittoSMosquitto.initialize()letsmosquitto=SMosquitto(id:"An ID", cleanSession:true)try smosquitto.setLoginInformation(username:"username", password:"password")try smosquitto.connect(host:"hostname", port:1883, keepalive:true)smosquitto.onConnect={ responseindo{        // Subscribe for topics once connected to server.try smosquitto.subscribe(subscriptionPattern:"atopic", qos:.atleastOnce)}catch{        // an error happened}}smosquitto.onMessage={ messagein  // Do something with received message}/// Start async looptry smosquitto.loopForever(timeout:.interval(45))

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.Please make sure to update tests as appropriate.

About

Lightweight Swift wrapper around libmosquitto client library.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2026 Movatter.jp