fix ping, fix send frame close (#49)
* fix ping, fix send frame close * fixes for data race on _closeCode etc. and fix test * fixing one TC * fix waiting forever if no time to change of readyState, and poll never end * add 1005 code if no status code received * fixes for 1005 code * fix test issue * fix macOS issue * revert to master tests and renaming
This commit is contained in:
committed by
Benjamin Sergeant
parent
c0a80264d1
commit
0d83ffdf6e
@ -215,6 +215,11 @@ namespace ix
|
||||
return getReadyState() == WebSocket_ReadyState_Closing;
|
||||
}
|
||||
|
||||
bool WebSocket::isConnectedOrClosing() const
|
||||
{
|
||||
return isConnected() || isClosing();
|
||||
}
|
||||
|
||||
void WebSocket::close(uint16_t code,
|
||||
const std::string& reason)
|
||||
{
|
||||
@ -230,7 +235,7 @@ namespace ix
|
||||
millis duration;
|
||||
|
||||
// Try to connect only once when we don't have automaticReconnection setup
|
||||
if (!isConnected() && !isClosing() && !_stop && !_automaticReconnection)
|
||||
if (!isConnectedOrClosing() && !_stop && !_automaticReconnection)
|
||||
{
|
||||
status = connect(_handshakeTimeoutSecs);
|
||||
|
||||
@ -252,7 +257,7 @@ namespace ix
|
||||
// Otherwise try to reconnect perpertually
|
||||
while (true)
|
||||
{
|
||||
if (isConnected() || isClosing() || _stop || !_automaticReconnection)
|
||||
if (isConnectedOrClosing() || _stop || !_automaticReconnection)
|
||||
{
|
||||
break;
|
||||
}
|
||||
@ -287,20 +292,17 @@ namespace ix
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (_stop) return;
|
||||
if (_stop && !isClosing()) return;
|
||||
|
||||
// 1. Make sure we are always connected
|
||||
reconnectPerpetuallyIfDisconnected();
|
||||
|
||||
if (_stop) return;
|
||||
|
||||
// 2. Poll to see if there's any new data available
|
||||
_ws.poll();
|
||||
|
||||
if (_stop) return;
|
||||
WebSocketTransport::PollPostTreatment pollPostTreatment = _ws.poll();
|
||||
|
||||
// 3. Dispatch the incoming messages
|
||||
_ws.dispatch(
|
||||
pollPostTreatment,
|
||||
[this](const std::string& msg,
|
||||
size_t wireSize,
|
||||
bool decompressionError,
|
||||
@ -341,7 +343,7 @@ namespace ix
|
||||
});
|
||||
|
||||
// If we aren't trying to reconnect automatically, exit if we aren't connected
|
||||
if (!isConnected() && !_automaticReconnection) return;
|
||||
if (!isConnectedOrClosing() && !_automaticReconnection) return;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user