• This repository has been archived on 05/Apr/2019
  • Stars
    star
    177
  • Rank 215,168 (Top 5 %)
  • Language
    Objective-C
  • License
    zlib License
  • Created almost 14 years ago
  • Updated almost 13 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Cocoa interface to Socket.IO by way of WebSockets.

This library does not work with Socket.IO 0.7. Philipp Kyeck has created another library that does - socket.IO-objc

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.