Network/TcpClient: WaitForConnected now returns new socket state
This commit is contained in:
parent
13a515c1b5
commit
dad2dbae1c
|
|
@ -148,6 +148,7 @@ Nazara Engine:
|
|||
- Added math class Angle, capable of handling both degrees and radians angles and converting them to euler angles/quaternions to improve 2D interface.
|
||||
- ⚠️ AbstractSocket::OnStateChange has been replaced by OnStateChanged, which is now called after state has been changed (with oldState and newState as parameters).
|
||||
- ⚠️ TcpClient::WaitForconnected now closes the socket on failure.
|
||||
- ⚠️ TcpClient::WaitForconnected now returns the new socket state.
|
||||
|
||||
Nazara Development Kit:
|
||||
- Added ImageWidget (#139)
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ namespace Nz
|
|||
|
||||
bool SetCursorPos(UInt64 offset) override;
|
||||
|
||||
bool WaitForConnected(UInt64 msTimeout = 3000);
|
||||
SocketState WaitForConnected(UInt64 msTimeout = 3000);
|
||||
|
||||
inline TcpClient& operator=(TcpClient&& tcpClient) = default;
|
||||
|
||||
|
|
|
|||
|
|
@ -432,24 +432,18 @@ namespace Nz
|
|||
|
||||
/*!
|
||||
* \brief Waits for being connected before time out
|
||||
* \return true If connection is successful
|
||||
* \return The new socket state, either Connected if connection did succeed or NotConnected if an error occurred
|
||||
*
|
||||
* \param msTimeout Time in milliseconds before time out
|
||||
* This functions waits for the pending connection to either succeed or fail for a specific duration before failing.
|
||||
*
|
||||
* \remark Produces a NazaraAssert if socket is invalid
|
||||
* \param msTimeout Time in milliseconds before time out (0 for system-specific duration, like a blocking connect would)
|
||||
*
|
||||
* \remark This function doesn't do anything if the socket is not currently connecting.
|
||||
*/
|
||||
|
||||
bool TcpClient::WaitForConnected(UInt64 msTimeout)
|
||||
SocketState TcpClient::WaitForConnected(UInt64 msTimeout)
|
||||
{
|
||||
switch (m_state)
|
||||
{
|
||||
case SocketState_Bound:
|
||||
case SocketState_Resolving:
|
||||
break;
|
||||
|
||||
case SocketState_Connected:
|
||||
return true;
|
||||
|
||||
case SocketState_Connecting:
|
||||
{
|
||||
NazaraAssert(m_handle != SocketImpl::InvalidHandle, "Invalid handle");
|
||||
|
|
@ -472,15 +466,20 @@ namespace Nz
|
|||
Close();
|
||||
|
||||
UpdateState(newState);
|
||||
return newState == SocketState_Connected;
|
||||
return newState;
|
||||
}
|
||||
|
||||
case SocketState_Connected:
|
||||
case SocketState_NotConnected:
|
||||
return false;
|
||||
return m_state;
|
||||
|
||||
case SocketState_Bound:
|
||||
case SocketState_Resolving:
|
||||
break;
|
||||
}
|
||||
|
||||
NazaraInternalError("Unhandled socket state (0x" + String::Number(m_state, 16) + ')');
|
||||
return false;
|
||||
return m_state;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
|||
Loading…
Reference in New Issue