forked from talkative/cocoa-websocket
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WebSocket.h
54 lines (43 loc) · 1.43 KB
/
WebSocket.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
//
// WebSocket.h
// Zimt
//
// Created by Esad Hajdarevic on 2/14/10.
// Copyright 2010 OpenResearch Software Development OG. All rights reserved.
//
#import <Foundation/Foundation.h>
@class AsyncSocket;
@class WebSocket;
@protocol WebSocketDelegate<NSObject>
@optional
- (void)webSocket:(WebSocket*)webSocket didFailWithError:(NSError*)error;
- (void)webSocketDidOpen:(WebSocket*)webSocket;
- (void)webSocketDidClose:(WebSocket*)webSocket;
- (void)webSocket:(WebSocket*)webSocket didReceiveMessage:(NSString*)message;
- (void)webSocketDidSendMessage:(WebSocket*)webSocket;
@end
@interface WebSocket : NSObject {
id<WebSocketDelegate> delegate;
NSURL* url;
AsyncSocket* socket;
BOOL connected;
NSString* origin;
NSArray* runLoopModes;
}
@property(nonatomic,assign) id<WebSocketDelegate> delegate;
@property(nonatomic,readonly) NSURL* url;
@property(nonatomic,retain) NSString* origin;
@property(nonatomic,readonly) BOOL connected;
@property(nonatomic,retain) NSArray* runLoopModes;
+ (id)webSocketWithURLString:(NSString*)urlString delegate:(id<WebSocketDelegate>)delegate;
- (id)initWithURLString:(NSString*)urlString delegate:(id<WebSocketDelegate>)delegate;
- (void)open;
- (void)close;
- (void)send:(NSString*)message;
@end
enum {
WebSocketErrorConnectionFailed = 1,
WebSocketErrorHandshakeFailed = 2
};
extern NSString *const WebSocketException;
extern NSString* const WebSocketErrorDomain;