Merge pull request #14079 from ZeroHackeR/v3

Fixing SocketIO - Connect failed after Disconnected
This commit is contained in:
pandamicro 2015-10-08 10:46:40 +08:00
commit 255edd5b46
1 changed files with 18 additions and 1 deletions

View File

@ -1199,7 +1199,24 @@ SIOClient* SocketIO::connect(const std::string& uri, SocketIO::SIODelegate& dele
socket->addClient(path, c);
socket->connectToEndpoint(path);
}
}else{
CCLOG("SocketIO: disconnect previous client");
c->disconnect();
CCLOG("SocketIO: recreate a new socket, new client, connect");
SIOClientImpl* newSocket = nullptr;
SIOClient *newC = nullptr;
newSocket = SIOClientImpl::create(host, port);
newC = new (std::nothrow) SIOClient(host, port, path, newSocket, delegate);
newSocket->addClient(path, newC);
newSocket->connect();
return newC;
}
}
return c;