-
-
Save aaronbuchanan/5df6887f76026bb25acb to your computer and use it in GitHub Desktop.
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
@implementation InterfaceController | |
{ | |
SRWebSocket *_webSocket; | |
} | |
- (void)awakeWithContext:(id)context { | |
[super awakeWithContext:context]; | |
} | |
- (IBAction)didOpen { | |
[_webSocket send:@"1"]; | |
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(500 * NSEC_PER_MSEC)), dispatch_get_main_queue(), ^{ | |
[_webSocket send:@"0"]; | |
}); | |
} | |
- (void)willActivate { | |
// This method is called when watch view controller is about to be visible to user | |
[super willActivate]; | |
[_webSocket close]; | |
_webSocket = nil; | |
_webSocket = [[SRWebSocket alloc] initWithURL:[NSURL URLWithString:API_URL]]; | |
_webSocket.delegate = self; | |
[_webSocket open]; | |
} | |
- (void)didDeactivate { | |
// This method is called when watch view controller is no longer visible | |
[super didDeactivate]; | |
if (_webSocket) { | |
[_webSocket send:@"0"]; | |
} | |
[_webSocket close]; | |
_webSocket = nil; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment