Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Cocoa interface to Socket.IO by way of WebSockets.
Objective-C
Branch: master
Failed to load latest commit information.
cocoa-websocket @ 9c38812
socketio-cocoa.xcodeproj Initial commit
.gitignore Initial commit
.gitmodules Adding in cocoa-websocket as a submodule
README.md Update README.md
SocketIoClient.h
SocketIoClient.m
ZLIB-LICENSE Adding headers and license.
socketio-cocoa_Prefix.pch Initial commit
socketio.m SocketIoClient gives the delegate callbacks when individual messages …

README.md

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.

Something went wrong with that request. Please try again.