Implementing player list for new lobby chat.
This commit is contained in:
@@ -730,7 +730,6 @@ AbstractClientStateReceiving::HandlePacket(boost::shared_ptr<ClientThread> clien
|
||||
if (netInfo->avatarData != NULL)
|
||||
{
|
||||
tmpInfo.hasAvatar = true;
|
||||
// TODO: use sha1.
|
||||
memcpy(tmpInfo.avatar.data, netInfo->avatarData->avatar.buf, MD5_DATA_SIZE);
|
||||
tmpInfo.avatarType = (AvatarFileType)netInfo->avatarData->avatarType;
|
||||
}
|
||||
@@ -840,11 +839,23 @@ AbstractClientStateReceiving::HandlePacket(boost::shared_ptr<ClientThread> clien
|
||||
else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_playerListMessage)
|
||||
{
|
||||
PlayerListMessage_t *netPlayerList = &tmpPacket->GetMsg()->choice.playerListMessage;
|
||||
PlayerInfo info;
|
||||
if (!client->GetCachedPlayerInfo(netPlayerList->playerId, info))
|
||||
|
||||
if (netPlayerList->playerListNotification == playerListNotification_playerListNew)
|
||||
{
|
||||
// Request player info.
|
||||
client->RequestPlayerInfo(netPlayerList->playerId);
|
||||
PlayerInfo info;
|
||||
if (!client->GetCachedPlayerInfo(netPlayerList->playerId, info))
|
||||
{
|
||||
// Request player info.
|
||||
ostringstream name;
|
||||
name << "#" << netPlayerList->playerId;
|
||||
info.playerName = name.str();
|
||||
client->RequestPlayerInfo(netPlayerList->playerId);
|
||||
}
|
||||
client->GetCallback().SignalLobbyPlayerJoined(netPlayerList->playerId, info.playerName);
|
||||
}
|
||||
else if (netPlayerList->playerListNotification == playerListNotification_playerListLeft)
|
||||
{
|
||||
client->GetCallback().SignalLobbyPlayerLeft(netPlayerList->playerId);
|
||||
}
|
||||
}
|
||||
else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_gameListMessage)
|
||||
|
||||
@@ -263,6 +263,8 @@ ServerLobbyThread::CloseSession(SessionWrapper session)
|
||||
m_sessionManager.RemoveSession(session.sessionData->GetId());
|
||||
m_gameSessionManager.RemoveSession(session.sessionData->GetId());
|
||||
|
||||
if (session.playerData)
|
||||
NotifyPlayerLeftLobby(session.playerData->GetUniqueId());
|
||||
// Update stats (if needed).
|
||||
UpdateStatisticsNumberOfPlayers();
|
||||
}
|
||||
@@ -274,6 +276,22 @@ ServerLobbyThread::ResubscribeLobbyMsg(SessionWrapper session)
|
||||
InternalResubscribeMsg(session);
|
||||
}
|
||||
|
||||
void
|
||||
ServerLobbyThread::NotifyPlayerJoinedLobby(unsigned playerId)
|
||||
{
|
||||
boost::shared_ptr<NetPacket> notify = CreateNetPacketPlayerListNew(playerId);
|
||||
m_sessionManager.SendLobbyMsgToAllSessions(GetSender(), notify, SessionData::Established);
|
||||
m_gameSessionManager.SendLobbyMsgToAllSessions(GetSender(), notify, SessionData::Game);
|
||||
}
|
||||
|
||||
void
|
||||
ServerLobbyThread::NotifyPlayerLeftLobby(unsigned playerId)
|
||||
{
|
||||
boost::shared_ptr<NetPacket> notify = CreateNetPacketPlayerListLeft(playerId);
|
||||
m_sessionManager.SendLobbyMsgToAllSessions(GetSender(), notify, SessionData::Established);
|
||||
m_gameSessionManager.SendLobbyMsgToAllSessions(GetSender(), notify, SessionData::Game);
|
||||
}
|
||||
|
||||
void
|
||||
ServerLobbyThread::NotifyPlayerJoinedGame(unsigned gameId, unsigned playerId)
|
||||
{
|
||||
@@ -1129,9 +1147,7 @@ ServerLobbyThread::EstablishSession(SessionWrapper session)
|
||||
m_statDataChanged = true;
|
||||
}
|
||||
// Notify all players.
|
||||
boost::shared_ptr<NetPacket> notify = CreateNetPacketPlayerListNew(session.playerData->GetUniqueId());
|
||||
m_sessionManager.SendLobbyMsgToAllSessions(GetSender(), notify, SessionData::Established);
|
||||
m_gameSessionManager.SendLobbyMsgToAllSessions(GetSender(), notify, SessionData::Game);
|
||||
NotifyPlayerJoinedLobby(session.playerData->GetUniqueId());
|
||||
|
||||
UpdateStatisticsNumberOfPlayers();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user