This library does not work with Socket.IO 0.7. Philipp Kyeck has created another library that does - socket.IO-objc
A Cocoa interface to Socket.IO by way of web sockets. If you're already using Socket.IO stuff for your web site, you might find it convenient to use the same architecture for your mobile stuff, too.
We use this with juggernaut-cocoa to work with Juggernaut, a realtime/push service based on Socket.IO.
SocketIoClient *client = [[SocketIoClient alloc] initWithHost:host port:port];
client.delegate = self;
[client connect];
[client send:@"Hello Socket.IO" isJSON:NO];
You'll get sweet callbacks on your delegate when stuff goes down...
- (void)socketIoClientDidConnect:(SocketIoClient *)client {
NSLog(@"Connected.");
}
- (void)socketIoClientDidDisconnect:(SocketIoClient *)client {
NSLog(@"Disconnected.");
}
- (void)socketIoClient:(SocketIoClient *)client didReceiveMessage:(NSString *)message isJSON:(BOOL)isJSON {
NSLog(@"Received: %@", message);
}
And, of course, all the normal heartbeat / reconnection stuff will happen for you behind the scenes.
- AsyncSocket http://code.google.com/p/cocoaasyncsocket/
- Cocoa WebSocket https://github.com/erichocean/cocoa-websocket
If you have git 1.7+ ...
git clone git://github.com/fpotter/socketio-cocoa.git --recursive
or, earlier...
git clone git://github.com/fpotter/socketio-cocoa.git socketio-cocoa
cd socketio-cocoa
git submodule init
git submodule update
Copy the AsyncSocket.h
, AsyncSocket.m
, WebSocket.h
, WebSocket.m
, SocketIoClient.h
, SocketIoClient.m
files to your project.
If you're building for iOS, make sure you add a reference to the CFNetwork
framework or you'll see compile errors from AsyncSocket.