Last active
August 29, 2015 14:02
-
-
Save pcperini/9e8535811117ee420883 to your computer and use it in GitHub Desktop.
WorldPin Socket Events
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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