This repository has been archived by the owner on Apr 5, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
/
SocketIoClient.h
78 lines (54 loc) · 2.03 KB
/
SocketIoClient.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//
// SocketIoClient.h
// SocketIoCocoa
//
// Created by Fred Potter on 11/11/10.
// Copyright 2010 Fred Potter. All rights reserved.
//
#import <Foundation/Foundation.h>
@class WebSocket;
@protocol SocketIoClientDelegate;
@interface SocketIoClient : NSObject {
NSString *_host;
NSInteger _port;
WebSocket *_webSocket;
NSTimeInterval _connectTimeout;
BOOL _tryAgainOnConnectTimeout;
NSTimeInterval _heartbeatTimeout;
NSTimer *_timeout;
BOOL _isConnected;
BOOL _isConnecting;
NSString *_sessionId;
id<SocketIoClientDelegate> _delegate;
NSMutableArray *_queue;
}
@property (nonatomic, retain, readonly) NSString *host;
@property (nonatomic, readonly) NSInteger port;
@property (nonatomic, retain) NSString *sessionId;
@property (nonatomic, readonly) BOOL isConnected;
@property (nonatomic, readonly) BOOL isConnecting;
@property (nonatomic, assign) id<SocketIoClientDelegate> delegate;
@property (nonatomic, assign) NSTimeInterval connectTimeout;
@property (nonatomic, assign) BOOL tryAgainOnConnectTimeout;
@property (nonatomic, assign) NSTimeInterval heartbeatTimeout;
- (id)initWithHost:(NSString *)host port:(NSInteger)port;
- (void)connect;
- (void)disconnect;
/**
* Rather than coupling this with any specific JSON library, you always
* pass in a string (either _the_ string, or the the JSON-encoded version
* of your object), and indicate whether or not you're passing a JSON object.
*/
- (void)send:(NSString *)data isJSON:(BOOL)isJSON;
@end
@protocol SocketIoClientDelegate <NSObject>
/**
* Message is always returned as a string, even when the message was meant to come
* in as a JSON object. Decoding the JSON is left as an exercise for the receiver.
*/
- (void)socketIoClient:(SocketIoClient *)client didReceiveMessage:(NSString *)message isJSON:(BOOL)isJSON;
- (void)socketIoClientDidConnect:(SocketIoClient *)client;
- (void)socketIoClientDidDisconnect:(SocketIoClient *)client;
@optional
- (void)socketIoClient:(SocketIoClient *)client didSendMessage:(NSString *)message isJSON:(BOOL)isJSON;
@end