- Notifications
You must be signed in to change notification settings - Fork0
Lightweight Swift wrapper around libmosquitto client library.
License
NotificationsYou must be signed in to change notification settings
S2Ler/SMosquitto
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Swift 5.0, macOS, Linux.
A thin Swift wrapper forlibmosquitto. Supports macOS and Linux.
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])
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))
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
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
No packages published