void CWaveSession::ProcessChannelResponse() { ASSERT(m_lpChannelRequest != NULL); CWaveReader * lpReader = (CWaveReader *)m_lpChannelRequest->GetReader(); ASSERT(lpReader != NULL); BOOL fSuccess = FALSE; fSuccess = m_nState == WSS_ONLINE && ( m_lpChannelRequest->GetResult() == CURLE_OK || m_lpChannelRequest->GetResult() == CURLE_OPERATION_TIMEOUTED ); if (fSuccess) { SetCookies(m_lpChannelRequest->GetCookies()); } delete lpReader; delete m_lpChannelRequest; m_lpChannelRequest = NULL; m_nRequesting = WSR_NONE; if (fSuccess) { // Continue the channel by posting the next request. PostChannelRequest(); } else if (m_nState == WSS_ONLINE) { // Only automatically reconnect when we're online. InitiateReconnect(); } }
bool InitWebControl() { if (g_bLoaded) return true; if (!LoadCEFDll()) return false; if (!g_pChromiumController) return false; RegisterJSBindings(); RegisterSchemes(); #ifdef NIX m_timeoutSource = g_timeout_add(50, onTimeout, nullptr); #endif g_bLoaded = true; SetCookies(); return true; }
void CWaveSession::ProcessCookieResponse() { ASSERT(m_lpRequest != NULL); if (m_lpRequest->GetResult() != CURLE_OK) { m_nLoginError = WLE_NETWORK; } else { SetCookies(m_lpRequest->GetCookies()); m_nLoginError = m_lpCookies == NULL ? WLE_AUTHENTICATE : WLE_SUCCESS; } delete m_lpRequest; m_lpRequest = NULL; m_nRequesting = WSR_NONE; if (m_nLoginError == WLE_SUCCESS) { SignalProgress(WCS_GOT_COOKIE); PostSessionDetailsRequest(); } else if (m_nState == WSS_RECONNECTING) { NextReconnect(); } else { m_nState = WSS_OFFLINE; SignalProgress(WCS_FAILED); } }
void IPCBrowser::setCookies(const char* freeman, const char* masterchief) { SetCookies(freeman, masterchief); }
void MainApp::onCookieUpdate() { SetCookies(); }
void CWaveSession::ProcessSIDResponse() { ASSERT(m_lpRequest != NULL); CCurlUTF8StringReader * lpReader = (CCurlUTF8StringReader *)m_lpRequest->GetReader(); ASSERT(lpReader != NULL); if (m_lpRequest->GetResult() != CURLE_OK) { m_nLoginError = WLE_NETWORK; } else { SetCookies(m_lpRequest->GetCookies()); wstring szChannelResponse(ExtractChannelResponse(lpReader->GetString())); if ( !szChannelResponse.empty() && ParseChannelResponse(szChannelResponse) ) { m_nLoginError = WLE_SUCCESS; } else { m_nLoginError = WLE_AUTHENTICATE; } } delete lpReader; delete m_lpRequest; m_lpRequest = NULL; m_nRequesting = WSR_NONE; if (m_nLoginError == WLE_SUCCESS) { m_nState = WSS_ONLINE; SignalProgress(WCS_LOGGED_ON); PostChannelRequest(); FlushRequestQueue(); } else { // When we were not able to log retireve the SID session, it could be // that the sticky session ID is not valid anymore. Invalidate. m_szStickySessionID = L""; if (m_nState == WSS_RECONNECTING) { NextReconnect(); } else { m_nState = WSS_OFFLINE; SignalProgress(WCS_FAILED); } } }
void CGamePlayer :: ProcessPackets( ) { if( !m_Socket ) return; CIncomingAction *Action = NULL; CIncomingChatPlayer *ChatPlayer = NULL; CIncomingMapSize *MapSize = NULL; uint32_t CheckSum = 0; uint32_t Pong = 0; // process all the received packets in the m_Packets queue while( !m_Packets.empty( ) ) { CCommandPacket *Packet = m_Packets.front( ); m_Packets.pop( ); if( Packet->GetPacketType( ) == W3GS_HEADER_CONSTANT ) { switch( Packet->GetID( ) ) { case CGameProtocol :: W3GS_LEAVEGAME: m_Game->EventPlayerLeft( this, m_Protocol->RECEIVE_W3GS_LEAVEGAME( Packet->GetData( ) ) ); break; case CGameProtocol :: W3GS_GAMELOADED_SELF: if( m_Protocol->RECEIVE_W3GS_GAMELOADED_SELF( Packet->GetData( ) ) ) { if( !m_FinishedLoading && m_Game->GetGameLoading( ) ) { m_FinishedLoading = true; m_FinishedLoadingTicks = GetTicks( ); m_Game->EventPlayerLoaded( this ); } else { // we received two W3GS_GAMELOADED_SELF packets from this player! } } break; case CGameProtocol :: W3GS_OUTGOING_ACTION: Action = m_Protocol->RECEIVE_W3GS_OUTGOING_ACTION( Packet->GetData( ), m_PID ); if( Action ) m_Game->EventPlayerAction( this, Action ); // don't delete Action here because the game is going to store it in a queue and delete it later break; case CGameProtocol :: W3GS_OUTGOING_KEEPALIVE: CheckSum = m_Protocol->RECEIVE_W3GS_OUTGOING_KEEPALIVE( Packet->GetData( ) ); m_CheckSums.push( CheckSum ); m_SyncCounter++; m_Game->EventPlayerKeepAlive( this, CheckSum ); break; case CGameProtocol :: W3GS_CHAT_TO_HOST: ChatPlayer = m_Protocol->RECEIVE_W3GS_CHAT_TO_HOST( Packet->GetData( ) ); if( ChatPlayer ) { // determine if we should auto-mute this player if( ChatPlayer->GetType( ) == CIncomingChatPlayer :: CTH_MESSAGE || ChatPlayer->GetType( ) == CIncomingChatPlayer :: CTH_MESSAGEEXTRA ) { m_MuteMessages.push_back( GetTicks( ) ); if( m_MuteMessages.size( ) > 7 ) m_MuteMessages.erase( m_MuteMessages.begin( ) ); uint32_t RecentCount = 0; for( unsigned int i = 0; i < m_MuteMessages.size( ); ++i ) { if( GetTicks( ) - m_MuteMessages[i] < 7000 ) RecentCount++; } if( !GetMuted( ) && RecentCount >= 7 ) { SetMuted( true ); m_MutedAuto = true; m_Game->SendAllChat( "[" + m_Name + "] has been automatically muted for spamming. (You will be unmuted momentarily, but please do not spam again!)" ); m_MuteMessages.clear( ); } //now check for flamers if( m_Game->m_GHost->FlameCheck( ChatPlayer->GetMessage( ) ) ) { m_FlameMessages.push_back( GetTicks( ) ); if( m_FlameMessages.size( ) > 10 ) m_FlameMessages.erase( m_FlameMessages.begin( ) ); RecentCount = 0; for( unsigned int i = 0; i < m_FlameMessages.size( ); ++i ) { if( GetTicks( ) - m_FlameMessages[i] < 80000 ) RecentCount++; } if( RecentCount >= 4 ) { m_Game->SendAllChat( "Use "+string(1, m_Game->m_GHost->m_CommandTrigger)+"ignore <playername> to ignore players (for example, if they are flaming); partial names work. Don't flame back!" ); m_FlameMessages.clear( ); } else if( RecentCount >= 3 ) { m_Game->SendAllChat( "[Calm] has refilled [" + GetName() + "]'s cookie jar. [" + GetName() + "] now has three cookies (try "+string(1, m_Game->m_GHost->m_CommandTrigger)+"eat)!"); SetCookies(3); } } } m_Game->EventPlayerChatToHost( this, ChatPlayer ); } delete ChatPlayer; ChatPlayer = NULL; break; case CGameProtocol :: W3GS_DROPREQ: // todotodo: no idea what's in this packet if( !m_DropVote ) { m_DropVote = true; m_Game->EventPlayerDropRequest( this ); } break; case CGameProtocol :: W3GS_MAPSIZE: m_ConnectionState = 2; m_ConnectionTime = GetTicks( ); MapSize = m_Protocol->RECEIVE_W3GS_MAPSIZE( Packet->GetData( ), m_Game->m_GHost->m_Map->GetMapSize( ) ); if( MapSize ) m_Game->EventPlayerMapSize( this, MapSize ); delete MapSize; MapSize = NULL; break; case CGameProtocol :: W3GS_PONG_TO_HOST: Pong = m_Protocol->RECEIVE_W3GS_PONG_TO_HOST( Packet->GetData( ) ); // we discard pong values of 1 // the client sends one of these when connecting plus we return 1 on error to kill two birds with one stone if( Pong != 1 ) { // we also discard pong values when we're downloading because they're almost certainly inaccurate // this statement also gives the player a 5 second grace period after downloading the map to allow queued (i.e. delayed) ping packets to be ignored if( !m_DownloadStarted || ( m_DownloadFinished && GetTime( ) - m_FinishedDownloadingTime >= 5 ) ) { // we also discard pong values when anyone else is downloading if we're configured to if( m_Game->m_GHost->m_PingDuringDownloads || !m_Game->IsDownloading( ) ) { m_Pings.push_back( GetTicks( ) - Pong ); if( m_Pings.size( ) > 20 ) m_Pings.erase( m_Pings.begin( ) ); } } } m_Game->EventPlayerPongToHost( this, Pong ); break; } } else if( Packet->GetPacketType( ) == GPS_HEADER_CONSTANT ) { BYTEARRAY Data = Packet->GetData( ); if( Packet->GetID( ) == CGPSProtocol :: GPS_INIT ) { if( m_Game->m_GHost->m_Reconnect ) { m_GProxy = true; m_Socket->PutBytes( m_Game->m_GHost->m_GPSProtocol->SEND_GPSS_INIT( m_Game->m_GHost->m_ReconnectPort, m_PID, m_GProxyReconnectKey, m_Game->GetGProxyEmptyActions( ) ) ); CONSOLE_Print( "[GAME: " + m_Game->GetGameName( ) + "] player [" + m_Name + "] is using GProxy++" ); } else { // todotodo: send notice that we're not permitting reconnects // note: GProxy++ should never send a GPS_INIT message if bot_reconnect = 0 because we don't advertise the game with invalid map dimensions // but it would be nice to cover this case anyway } } else if( Packet->GetID( ) == CGPSProtocol :: GPS_RECONNECT ) { // this is handled in ghost.cpp } else if( Packet->GetID( ) == CGPSProtocol :: GPS_ACK && Data.size( ) == 8 ) { uint32_t LastPacket = UTIL_ByteArrayToUInt32( Data, false, 4 ); uint32_t PacketsAlreadyUnqueued = m_TotalPacketsSent - m_GProxyBuffer.size( ); if( LastPacket > PacketsAlreadyUnqueued ) { uint32_t PacketsToUnqueue = LastPacket - PacketsAlreadyUnqueued; if( PacketsToUnqueue > m_GProxyBuffer.size( ) ) PacketsToUnqueue = m_GProxyBuffer.size( ); while( PacketsToUnqueue > 0 ) { m_GProxyBuffer.pop( ); PacketsToUnqueue--; } } } } delete Packet; } }