Socket Management

This commit is contained in:
Frederic Jacobs 2014-11-27 11:48:04 +01:00
parent 9b5379b3e2
commit 6446c6fbe0
3 changed files with 15 additions and 5 deletions

View File

@ -208,6 +208,7 @@
}
-(void) applicationDidBecomeActive:(UIApplication *)application {
[TSSocketManager becomeActive];
[AppAudioManager.sharedInstance awake];
// Hacky way to clear notification center after processed push
@ -231,8 +232,8 @@
completionHandler();
}
- (void)applicationWillResignActive:(UIApplication *)application{
[self protectScreen];
- (void)applicationDidEnterBackground:(UIApplication *)application{
[TSSocketManager resignActivity];
}
- (void)prepareScreenshotProtection{

View File

@ -163,7 +163,12 @@ NSString * const SocketConnectingNotification = @"SocketConnectingNotification";
[message setResponse:response.build];
[message setType:WebSocketMessageTypeResponse];
[self.websocket send:message.build.data];
@try {
[self.websocket send:message.build.data];
}
@catch (NSException *exception) {
DDLogWarn(@"Caught exception while trying to write on the socket %@", exception.debugDescription);
}
}
- (void)webSocket:(SRWebSocket *)webSocket didCloseWithCode:(NSInteger)code reason:(NSString *)reason wasClean:(BOOL)wasClean {
@ -174,7 +179,12 @@ NSString * const SocketConnectingNotification = @"SocketConnectingNotification";
}
- (void)webSocketHeartBeat {
[self.websocket sendPing:nil];
@try {
[self.websocket sendPing:nil];
}
@catch (NSException *exception) {
DDLogWarn(@"Caught exception while trying to write on the socket %@", exception.debugDescription);
}
}
- (NSString*)webSocketAuthenticationString{

View File

@ -23,7 +23,6 @@
}
NSData *identityKey = [NSData dataFromBase64String:identityKeyString];
NSLog(@"IDentityKey %@", identityKey);
for (NSDictionary *deviceDict in devicesArray) {
NSNumber *registrationIdString = [deviceDict objectForKey:@"registrationId"];