Skip to content

An easy to use Objective-C draft 10 websocket implementation

Notifications You must be signed in to change notification settings

zoopnin/MBWebSocketServer

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MBWebSocket

A websocket server implementation, (you cannot instantiate an instance that does not bind to a port).

NOTE! I have not tested it extensively and there are many old WS versions. So you may well have to hack it to make it work. But! There is not much code. And! I believe it is quite readable. I will help! Mail me!

Tested against recent Chrome, Safari and Firefox versions. Only tested on Mac.

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

Requirements

  • ARC or Garbage Collection
  • Xcode 4.5

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

About

An easy to use Objective-C draft 10 websocket implementation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published