Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
An objc draft 10 websocket implementation
Objective-C
tree: 8f697693cf

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
AsyncSocket.h
AsyncSocket.m
MBWebSocketServer.h
MBWebSocketServer.m
README.md

README.md

MBWebSocket

So far just a server implementation, (you cannot instantiate an instance that does not bind to a port). Also, the server can only manage a single connection at a time.

So, seriously, you will probably have to do some work to this class to make it work how you need it too. But it’s nice and simple so just get straight in.

Tested against Chrome 10/2011. Probably will only work against that.

If you want a client implementation, use Square’s SocketRocket.

Example Usage

- (void)applicationDidFinishLaunching:(NSNotification *)note {
    self.ws = [[MBWebSocketServer alloc] initWithPort:13581 delegate:self];
}

- (void)webSocketServerDidConnect:(MBWebSocketServer *)webSocket {
    NSLog(@"Connected to a client (and we only work with one for now!)");
}

- (void)webSocketServer:(MBWebSocketServer *)webSocket didReceiveData:(NSData *)data
{
    NSLog(@"%@", [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
    [webSocket send:@"Thanks!"];
}

- (void)webSocketServerDidDisconnect:(MBWebSocketServer *)webSocket {
    NSLog(@"Disconnected from client");
}

Author

I’m Max Howell and I'm a splendid chap

Something went wrong with that request. Please try again.