Skip to content

Instantly share code, notes, and snippets.

@pcperini
Last active August 29, 2015 14:02
Show Gist options
  • Save pcperini/9e8535811117ee420883 to your computer and use it in GitHub Desktop.
Save pcperini/9e8535811117ee420883 to your computer and use it in GitHub Desktop.
WorldPin Socket Events
- (void)viewDidLoad
{
[super viewDidLoad];
[SIOSocket socketWithHost: @"http://yourHost:3000" response: ^(SIOSocket *socket)
{
self.socket = socket;
__weak typeof(self) weakSelf = self;
self.socket.onConnect = ^()
{
weakSelf.socketIsConnected = YES;
[weakSelf mapView: weakSelf.mapView didUpdateUserLocation: weakSelf.mapView.userLocation];
};
[self.socket on: @"join" callback: ^(SIOParameterArray *args)
{
[weakSelf mapView: weakSelf.mapView didUpdateUserLocation: weakSelf.mapView.userLocation];
}];
[self.socket on: @"disappear" callback: ^(SIOParameterArray *args)
{
NSString *pinID = [args firstObject];
[self.mapView removeAnnotation: self.pins[pinID]];
[self.pins removeObjectForKey: pinID];
}];
}];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment