Skip to content

Instantly share code, notes, and snippets.

@guilleiguaran
Created March 5, 2015 18:31
Show Gist options
  • Save guilleiguaran/7905f4f7ae65c456c1d0 to your computer and use it in GitHub Desktop.
Save guilleiguaran/7905f4f7ae65c456c1d0 to your computer and use it in GitHub Desktop.
NSURL *url = [NSURL URLWithString:@"ws://localhost:4000/ws"];
// Opens connection to Phoenix
_phoenix = [[Phoenix alloc] initWithURL:url];
[_phoenix setDelegate:self];
[_phoenix open];
// Creates, listens on, and joins channel
_channel = [[PhoenixChannel alloc] initWithTopic:@"locations:1" payload:nil withPhoenix:_phoenix];
[_channel on:@"driver:location" handleEventBlock:^(id message) {
NSLog(@"Message - %@", message);
}];
[_channel join];
[_channel sendEvent:@"driver:location" payload:@{ @"location" : @"-47,11" }];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment