83 lines
2.0 KiB
Objective-C
Executable File
83 lines
2.0 KiB
Objective-C
Executable File
//
|
|
// ManagerMqtt.h
|
|
// SoundRiver
|
|
//
|
|
// Created by apple on 2020/3/19.
|
|
//
|
|
|
|
#import <Foundation/Foundation.h>
|
|
#import "MQTTClient.h"
|
|
#import "MQTTSessionManager.h"
|
|
#import <CommonCrypto/CommonHMAC.h>
|
|
//typedef NS_ENUM(NSInteger) {
|
|
// /// 巡乐会进度更新
|
|
// QXManagerMqttTypeAcProgress = 100,
|
|
// /// 巡乐会即将开始
|
|
// QXManagerMqttTypeAcWill = 101,
|
|
// /// 巡乐会已经开始
|
|
// QXManagerMqttTypeAcStart = 102,
|
|
// /// 巡乐会结束落包
|
|
// QXManagerMqttTypeAcEnd = 103,
|
|
// /// 有人锁定了礼物
|
|
// QXManagerMqttTypeAcLock = 103,
|
|
//}QXManagerMqttType;
|
|
|
|
/// 礼物话题
|
|
static NSString * _Nonnull qx_room_topic = @"qx_room_topic";
|
|
/// 巡乐会话题
|
|
static NSString * _Nonnull qx_ac_topic = @"qx_xunlehui";
|
|
/// 小时榜话题
|
|
static NSString * _Nonnull qx_hour_ranking = @"qx_hour_ranking";
|
|
/// 红包话题
|
|
static NSString * _Nonnull qx_red_redpacket = @"qx_redpacket_arrive";
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
@protocol MQTTClientModelDelegate <NSObject>
|
|
@optional
|
|
- (void)MQTTClientModel_handleMessage:(NSData *)data onTopic:(NSString *)topic retained:(BOOL)retained;
|
|
- (void)socketManager:(NSString *)socketManager receivedMessage:(NSDictionary *)message topic:(NSString *)topic;
|
|
|
|
@end
|
|
|
|
|
|
@interface QXManagerMqtt : NSObject
|
|
@property (nonatomic, assign) BOOL isDiscontent;
|
|
@property (nonatomic, weak) id <MQTTClientModelDelegate> delegate;
|
|
|
|
@property (nonatomic,strong,nullable) MQTTSessionManager *mySessionManager;
|
|
|
|
+ (instancetype)sharedInstance;
|
|
|
|
|
|
- (void)bindWithUserName:(NSString *)username password:(NSString *)password cliendId:(NSString *)cliendId isSSL:(BOOL)isSSL;
|
|
|
|
- (void)disconnect;
|
|
|
|
- (void)reConnect;
|
|
|
|
/**
|
|
订阅主题
|
|
|
|
@param topic 主题
|
|
*/
|
|
typedef void (^SubscribeTopicHandler)(NSString *topic, BOOL success);
|
|
|
|
- (void)subscribeTopic:(NSString *)topic;
|
|
|
|
/**
|
|
取消订阅
|
|
|
|
@param topic 主题
|
|
*/
|
|
- (void)unsubscribeTopic:(NSString *)topic;
|
|
|
|
/**
|
|
发布消息
|
|
*/
|
|
- (void)sendDataToTopic:(NSString *)topic dict:(NSDictionary *)dict;
|
|
|
|
|
|
@end
|
|
|
|
NS_ASSUME_NONNULL_END
|