如果服务端退出,再重新启动,那么客户端就没法再连上。我在SocketIO.cpp改了一点,这样可以自动重连:
bool SIOClient::isConnected()
{
return _connected;
}
```
然后SocketIO::connect最后增加了对client的判断:
else
{
//check if already connected to endpoint, handle
c = socket->getClient(path);
if(c == NULL)
{
c = new SIOClient(host, port, path, socket, delegate);
socket->addClient(path, c);
socket->connectToEndpoint(path);
}
else if (!c->isConnected())
{
socket->connect();
}
}
```
这样客户端起码能自动重连了,但不知道会有什么问题。