My SIOSocket get disconnected in ios without going to background

237 Views Asked by At

Below is the event from where i handle all connection and disconnection event but while my app is running in between my socket connection is disconnected from client side not from server side but it not fired disconnected event so i cannot handle this disconnected event of socket.How can i solve it? App does not go to background. Is there any solution to detect the disconnection event?

[SIOSocket socketWithHost: @"https://localHost:3003" response:^(SIOSocket *socket)
 {

_SocketIO = socket; _SocketIO.onConnect =^() 
{ 

     NSLog(@"connected"); 
};

 [_SocketIO on: @"res" callback: ^(SIOParameterArray *args)
  {
      [self.delegate ResponcewithDict:[args objectAtIndex:0]];
  }];
 _SocketIO.onConnectError =^(NSDictionary *dict)
 {
     NSLog(@"connection error");
 };

 _SocketIO.onDisconnect=^()
 {
  // [((ViewController *)[AppDelegate sharedInstance].window.rootViewController) onDisconnect];
     ISConnected = false;
     NSLog(@"disconnect");
 };

 _SocketIO.onError=^(NSDictionary *dict)
 {
     NSLog(@"error");
     ISConnected = false;
 };

 _SocketIO.onReconnect=^(NSInteger i)
 {
     NSLog(@"reconn");
     ISConnected = true;enter code here
 };

 }];
0

There are 0 best solutions below