commit | author | age
|
ea8e18
|
1 |
// |
L |
2 |
// MQTTDecoder.h |
|
3 |
// MQTTClient.framework |
|
4 |
// |
|
5 |
// Copyright © 2013-2016, Christoph Krey |
|
6 |
// |
|
7 |
// based on |
|
8 |
// |
|
9 |
// Copyright (c) 2011, 2013, 2lemetry LLC |
|
10 |
// |
|
11 |
// All rights reserved. This program and the accompanying materials |
|
12 |
// are made available under the terms of the Eclipse Public License v1.0 |
|
13 |
// which accompanies this distribution, and is available at |
|
14 |
// http://www.eclipse.org/legal/epl-v10.html |
|
15 |
// |
|
16 |
// Contributors: |
|
17 |
// Kyle Roche - initial API and implementation and/or initial documentation |
|
18 |
// |
|
19 |
|
|
20 |
#import <Foundation/Foundation.h> |
|
21 |
#import "MQTTMessage.h" |
|
22 |
|
|
23 |
typedef enum { |
|
24 |
MQTTDecoderEventProtocolError, |
|
25 |
MQTTDecoderEventConnectionClosed, |
|
26 |
MQTTDecoderEventConnectionError |
|
27 |
} MQTTDecoderEvent; |
|
28 |
|
|
29 |
typedef enum { |
|
30 |
MQTTDecoderStateInitializing, |
|
31 |
MQTTDecoderStateDecodingHeader, |
|
32 |
MQTTDecoderStateDecodingLength, |
|
33 |
MQTTDecoderStateDecodingData, |
|
34 |
MQTTDecoderStateConnectionClosed, |
|
35 |
MQTTDecoderStateConnectionError, |
|
36 |
MQTTDecoderStateProtocolError |
|
37 |
} MQTTDecoderState; |
|
38 |
|
|
39 |
@class MQTTDecoder; |
|
40 |
|
|
41 |
@protocol MQTTDecoderDelegate <NSObject> |
|
42 |
|
|
43 |
- (void)decoder:(MQTTDecoder *)sender didReceiveMessage:(NSData *)data; |
|
44 |
- (void)decoder:(MQTTDecoder *)sender handleEvent:(MQTTDecoderEvent)eventCode error:(NSError *)error; |
|
45 |
|
|
46 |
@end |
|
47 |
|
|
48 |
|
|
49 |
@interface MQTTDecoder : NSObject <NSStreamDelegate> |
|
50 |
@property (nonatomic) MQTTDecoderState state; |
|
51 |
@property (strong, nonatomic) NSRunLoop* runLoop; |
|
52 |
@property (strong, nonatomic) NSString* runLoopMode; |
|
53 |
@property (nonatomic) UInt32 length; |
|
54 |
@property (nonatomic) UInt32 lengthMultiplier; |
|
55 |
@property (nonatomic) int offset; |
|
56 |
@property (strong, nonatomic) NSMutableData* dataBuffer; |
|
57 |
|
|
58 |
@property (weak, nonatomic ) id<MQTTDecoderDelegate> delegate; |
|
59 |
|
|
60 |
- (void)open; |
|
61 |
- (void)close; |
|
62 |
- (void)decodeMessage:(NSData *)data; |
|
63 |
@end |
|
64 |
|
|
65 |
|