Ver Fonte

Adding receiving of close messages to demo app

Mike Lewis há 13 anos atrás
pai
commit
69ad9ea5bf
1 ficheiros alterados com 8 adições e 0 exclusões
  1. 8 0
      TestChat/TCViewController.m

+ 8 - 0
TestChat/TCViewController.m

@@ -117,6 +117,7 @@
     NSLog(@":( Websocket Failed With Error %@", error);
     
     self.title = @"Connection Failed! (see logs)";
+    _webSocket = nil;
 }
 
 - (void)webSocket:(SRWebSocket *)webSocket didReceiveMessage:(NSString *)message;
@@ -127,6 +128,13 @@
     [self.tableView scrollRectToVisible:self.tableView.tableFooterView.frame animated:YES];
 }
 
+- (void)webSocket:(SRWebSocket *)webSocket didCloseWithCode:(NSInteger)code reason:(NSString *)reason wasClean:(BOOL)wasClean;
+{
+    NSLog(@"WebSocket closed");
+    self.title = @"Connection Closed! (see logs)";
+    _webSocket = nil;
+}
+
 - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text;
 {
     if ([text rangeOfString:@"\n"].location != NSNotFound) {