bool NXConnection::Advance( unsigned int timeout ) { if( ErrorOccurred() ) return false; if( !pProxy && SessionNeedToStartNewProxy( pSession) == NX_Ok ) { NX_LOG_LOGDEBUG( "create proxy connection."); pProxy = CreateProxyConnection( pSession ); if( InitProxyConnection( pProxy ) == NX_Exception ) return false; } int iState = GetStateId(); if( iState >= NX_ReadyForConnection && iState < NX_InitProxy ) { if( EndServerConnection( pConnection ) != NX_Ok ) { return ( AdvanceServerConnection( pConnection, timeout ) != NX_Exception ); } } if( pProxy && EndProxyConnection( pProxy ) != NX_Ok ) { if ( AdvanceProxyConnection( pProxy, timeout ) != NX_Exception ) return ( AdvanceServerConnection( pConnection, timeout ) != NX_Exception ); } return true; }
/** * @brief Deals with completed send operation. * * @param socket [in,out] Pointer to socket that initiated send operation. * @param overlapped Pointer to WSAOVERLAPPED object associated with send operation. * @param success True if the operation completed successfully. * @param shuttingDown True if the operation failed but this was because the socket is shutting down. * @param clientID ID of client that initiated send operation, may be ignored. */ void NetInstance::CompletedSendOperation(NetSocket * socket, const WSAOVERLAPPED * overlapped, bool success, bool shuttingDown, size_t clientID) { socket->CompletedSendOperation(overlapped,success,shuttingDown); if(socket->GetCompletionPortCloseRequest() == true) { ErrorOccurred(clientID); } }
std::string Status::Print() const { std::string str = "Status<"; if (ErrorOccurred(ErrorType::NONE)) { str += "OK"; } else { str += "ERROR:"; if (ErrorOccurred(ErrorType::SOCKET)) { str += " [in socket: " + std::to_string(socket_status) + "]"; } if (ErrorOccurred(ErrorType::SERVER)) { str += " [server error code: " + std::to_string(error_code) + ", message: " + error_message + "]"; } if (ErrorOccurred(ErrorType::NO_DATA_RECEIVED)) { str += " [no data received in blocking mode]"; } } str.push_back('>'); return str; }
string NXConnection::GetState() const { if( ErrorOccurred() ) return "Connection error"; string sRet = ""; switch( GetCurrentState( pSession ) ) { case NX_ReadyForConnection: sRet = "Initializing connection"; break; case NX_Connecting: sRet = "Connecting to '"; sRet += string( GetStringParameter( pSession, NX_HostName, "unknown" ) ); sRet += "'"; break; case NX_Connected: sRet = "Connected to '"; sRet += string( GetStringParameter( pSession, NX_HostName, "unknown" ) ); sRet += "'"; break; case NX_SendingVersion: case NX_AcceptingVersion: sRet = "Negotiating protocol version"; break; case NX_VersionAccepted: sRet = "NX protocol version accepted"; break; case NX_WaitingForAuth: case NX_SendingAuth: case NX_Authenticating: sRet = "Waiting for authentication"; break; case NX_Authenticated: case NX_StartingSession: sRet = "Authentication completed"; break; case NX_SendingParameters: case NX_Negotiating: sRet = "Negotiating session parameters"; break; case NX_SessionAccepted: sRet = "Starting session"; break; case NX_ConnectionEnd: sRet = ""; break; case NX_ProxyReady: sRet = "Starting session"; break; case NX_ProxyConnecting: sRet = "Initializing X protocol compression"; break; case NX_ProxyNegotiating: sRet = "Negotiating link parameters"; break; case NX_ProxyConnected: sRet = "Established X server connection"; break; case NX_ProxyConnectionEnd: sRet = ""; break; default: sRet = ""; } return sRet; }