Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
@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
@prasadgau

This comment has been minimized.

Copy link

@prasadgau prasadgau commented Feb 10, 2017

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.