在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):novastone-media/MQTT-Client-Framework开源软件地址(OpenSource Url):https://github.com/novastone-media/MQTT-Client-Framework开源编程语言(OpenSource Language):Objective-C 97.2%开源软件介绍(OpenSource Introduction):MQTT-Client-Framework is a native Objective-C iOS library. It uses You can read introduction to learn more about framework. MQTT-Client-Framework is tested with a long list of brokers:
UsageFor example app, see MQTTChat Create a new client and connect to a broker: #import "MQTTClient.h"
MQTTCFSocketTransport *transport = [[MQTTCFSocketTransport alloc] init];
transport.host = @"test.mosquitto.org";
transport.port = 1883;
MQTTSession *session = [[MQTTSession alloc] init];
session.transport = transport;
[session connectWithConnectHandler:^(NSError *error) {
// Do some work
}]; Subscribe to a topic: [session subscribeToTopic:@"example/#" atLevel:MQTTQosLevelExactlyOnce subscribeHandler:^(NSError *error, NSArray<NSNumber *> *gQoss) {
if (error) {
NSLog(@"Subscription failed %@", error.localizedDescription);
} else {
NSLog(@"Subscription sucessfull! Granted Qos: %@", gQoss);
}
}];
In your - (void)newMessage:(MQTTSession *)session data:(NSData *)data onTopic:(NSString *)topic qos:(MQTTQosLevel)qos retained:(BOOL)retained mid:(unsigned int)mid {
// New message received in topic
} Publish a message to a topic: [session publishData:someData onTopic:@"example/#" retain:NO qos:MQTTQosLevelAtMostOnce publishHandler:^(NSError *error) {
}]; If you already have a self signed URL from broker like AWS IoT endpoint, use the MQTTWebsocketTransport *transport = [[MQTTWebsocketTransport alloc] init];
transport.url = @"wss://aws.iot-amazonaws.com/mqtt?expiry='2018-05-01T23:12:32.950Z'"
MQTTSession *session = [[MQTTSession alloc] init];
session.transport = transport;
[session connectWithConnectHandler:^(NSError *error) {
// Do some work
}]; InstallationCocoaPodsAdd this to your Podfile:
which is a short for:
The Manager subspec includes the If you want to use MQTT over Websockets:
If you want to do your logging with CocoaLumberjack (recommended):
CarthageIn your Cartfile:
ManuallyGit submodule
Framework
Security DisclosureIf you believe you have identified a security vulnerability with MQTT-Client-Framework, please report it to [email protected] and do not post it to a public issue tracker. ThanksThis project was originally written by Christoph Krey. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论