下面是我处理所有连接和断开连接事件的事件,但是我的应用程序运行之间我的套接字连接从客户端而不是从服务器端断开但它没有触发断开连接的事件,所以我无法处理这个断开连接的事件socket.How我能解决吗?应用程序不会转到后台。有没有解决方案来检测断线事件?
[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
};
}];