Update WebSocket.cpp

bufix: when connecting fail, libwebsocket_client_connect() will return NULL, and onSocketCallback() will not be called, so we need trigger WS_MSG_TO_UITHREAD_ERROR here.
This commit is contained in:
Raymond Xie 2014-01-26 15:59:14 +08:00
parent 603df24d0e
commit d8b1f78039
1 changed files with 8 additions and 0 deletions

View File

@ -442,6 +442,14 @@ void WebSocket::onSubThreadStarted()
_wsInstance = libwebsocket_client_connect(_wsContext, _host.c_str(), _port, _SSLConnection,
_path.c_str(), _host.c_str(), _host.c_str(),
name.c_str(), -1);
if(NULL == _wsInstance) {
WsMessage* msg = new WsMessage();
msg->what = WS_MSG_TO_UITHREAD_ERROR;
_readyState = kStateClosing;
_wsHelper->sendMessageToUIThread(msg);
}
}
}