lipengwei
2020-05-06 d8c7af0ebe241beb9270ba597a8d2dd9ca3275e9
commit | author | age
ea8e18 1 //
L 2 // MQTTCFSocketEncoder.h
3 // MQTTClient.framework
4 //
5 // Copyright © 2013-2016, Christoph Krey
6 //
7
8 #import <Foundation/Foundation.h>
9
10 typedef NS_ENUM(NSInteger, MQTTCFSocketEncoderState) {
11     MQTTCFSocketEncoderStateInitializing,
12     MQTTCFSocketEncoderStateReady,
13     MQTTCFSocketEncoderStateError
14 };
15
16 @class MQTTCFSocketEncoder;
17
18 @protocol MQTTCFSocketEncoderDelegate <NSObject>
19 - (void)encoderDidOpen:(MQTTCFSocketEncoder *)sender;
20 - (void)encoder:(MQTTCFSocketEncoder *)sender didFailWithError:(NSError *)error;
21 - (void)encoderdidClose:(MQTTCFSocketEncoder *)sender;
22
23 @end
24
25 @interface MQTTCFSocketEncoder : NSObject <NSStreamDelegate>
26 @property (nonatomic) MQTTCFSocketEncoderState state;
27 @property (strong, nonatomic) NSError *error;
28 @property (strong, nonatomic) NSOutputStream *stream;
29 @property (strong, nonatomic) NSRunLoop *runLoop;
30 @property (strong, nonatomic) NSString *runLoopMode;
31 @property (weak, nonatomic ) id<MQTTCFSocketEncoderDelegate> delegate;
32
33 - (void)open;
34 - (void)close;
35 - (BOOL)send:(NSData *)data;
36
37 @end
38