Created
April 28, 2015 10:58
-
-
Save arbarlow/68b41fa7f2c5aa74e0ac to your computer and use it in GitHub Desktop.
This file contains hidden or 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
Hi, I am trying to use socket in watch kit but i am not able to get any socket which is supported to iWatch OS. But here it was mentioned here to support the iWatch OS. Can you provide the entire library which will support to iWatch?