Skip to content

Cocoa interface to Socket.IO by way of WebSockets.

License

Notifications You must be signed in to change notification settings

bejo/socketio-cocoa

 
 

Repository files navigation

Socket.IO Client for Cocoa

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.

Usage

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.

Depends on

Getting the code

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

Adding to your project

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.

About

Cocoa interface to Socket.IO by way of WebSockets.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Objective-C 81.3%
  • C 18.7%