forked from talkative/cocoa-websocket
-
Notifications
You must be signed in to change notification settings - Fork 1
/
WebSocketAppDelegate.m
51 lines (40 loc) · 1.15 KB
/
WebSocketAppDelegate.m
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
//
// WebSocketAppDelegate.m
// WebSocket
//
// Created by Erich Ocean on 4/13/10.
// Copyright 2010 Erich Atlas Ocean. All rights reserved.
//
#import "WebSocketAppDelegate.h"
@implementation WebSocketAppDelegate
@synthesize window;
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
webSocket = [[WebSocket alloc] initWithURLString:@"ws://localhost:8888/socket.io/websocket" delegate:self];
[webSocket open];
}
-(void)webSocketDidClose:(WebSocket *)ws {
NSLog(@"Connection closed");
}
-(void)webSocket:(WebSocket *)ws didFailWithError:(NSError *)error {
if (error.code == WebSocketErrorConnectionFailed) {
NSLog(@"Connection failed");
} else if (error.code == WebSocketErrorHandshakeFailed) {
NSLog(@"Handshake failed");
} else {
NSLog(@"Error");
}
}
-(void)webSocket:(WebSocket *)ws didReceiveMessage:(NSString*)message {
NSLog(@"Received: %@", message);
}
-(void)webSocketDidOpen:(WebSocket *)ws {
NSLog(@"Connected");
}
-(void)webSocketDidSendMessage:(WebSocket *)ws {
NSLog(@"Did send message");
}
-(void) dealloc {
[webSocket release];
[super dealloc];
}
@end