Exemple #1
0
void SRVServer::onSocketClosed(MySocket* _pSocket)
{
    ClientSocket* pClientSocket = reinterpret_cast<ClientSocket*>( _pSocket );

    int32_t userID = pClientSocket->GetID();

    // Send "LEAVE_CHAT" to the Chat Server
    if(userID >= WS_USERS_AUTO_INCREMENT_OFFSET)
    {

        uint32_t logicID = LOGIC_ID_CHESS;
        TVecChar data;
        data.assign( (char*)&logicID, (char*)&logicID + sizeof(logicID) );

        ClientMsg msg;
        msg.InitMsg( CHAT, CMD_CHAT_LEAVE, data );

        RegInfo regInfo;
        regInfo.SetID(userID); // simulate a message from the user

        ClientMsg dummy;
        Register(&msg, &dummy, &regInfo);

    }
}
Exemple #2
0
void SRVServer::RemoveSocket( MySocket* _pSocket )
{
	ClientSocket* pClientSocket = reinterpret_cast<ClientSocket*>( _pSocket );


	int32_t userID = 0;

	if( pClientSocket &&  ( userID = pClientSocket->GetID()) )
    {
          m_pOnLineManager->OffLine( userID );
    }

#ifdef LOW_LEVEL_DEBUG
    cout << "SOCKET " << _pSocket->GetSocket() << " SRVServer::RemoveSocket. DELETE SOCKET" << endl;
#endif

	SocketManager::RemoveSocket( _pSocket );
}