Implementing player list for new lobby chat.
This commit is contained in:
@@ -158,3 +158,7 @@ void ServerGuiWrapper::SignalIrcPlayerLeft(const string &nickName) { if (myIrccb
|
|||||||
void ServerGuiWrapper::SignalIrcChatMsg(const string &nickName, const string &msg) { if (myIrccb) myIrccb->SignalIrcChatMsg(nickName, msg); }
|
void ServerGuiWrapper::SignalIrcChatMsg(const string &nickName, const string &msg) { if (myIrccb) myIrccb->SignalIrcChatMsg(nickName, msg); }
|
||||||
void ServerGuiWrapper::SignalIrcError(int errorCode) { if (myIrccb) myIrccb->SignalIrcError(errorCode); }
|
void ServerGuiWrapper::SignalIrcError(int errorCode) { if (myIrccb) myIrccb->SignalIrcError(errorCode); }
|
||||||
void ServerGuiWrapper::SignalIrcServerError(int errorCode) {if (myIrccb) myIrccb->SignalIrcServerError(errorCode); }
|
void ServerGuiWrapper::SignalIrcServerError(int errorCode) {if (myIrccb) myIrccb->SignalIrcServerError(errorCode); }
|
||||||
|
|
||||||
|
void ServerGuiWrapper::SignalLobbyPlayerJoined(unsigned playerId, const std::string &nickName) { if (myClientcb) myClientcb->SignalLobbyPlayerJoined(playerId, nickName); }
|
||||||
|
void ServerGuiWrapper::SignalLobbyPlayerKicked(const std::string &nickName, const std::string &byWhom, const std::string &reason) { if (myClientcb) myClientcb->SignalLobbyPlayerKicked(nickName, byWhom, reason); }
|
||||||
|
void ServerGuiWrapper::SignalLobbyPlayerLeft(unsigned playerId) { if (myClientcb) myClientcb->SignalLobbyPlayerLeft(playerId); }
|
||||||
|
|||||||
@@ -145,6 +145,9 @@ public:
|
|||||||
void SignalNetClientMsgBox(const std::string &msg);
|
void SignalNetClientMsgBox(const std::string &msg);
|
||||||
void SignalIrcError(int errorCode);
|
void SignalIrcError(int errorCode);
|
||||||
void SignalIrcServerError(int errorCode);
|
void SignalIrcServerError(int errorCode);
|
||||||
|
void SignalLobbyPlayerJoined(unsigned playerId, const std::string &nickName);
|
||||||
|
void SignalLobbyPlayerKicked(const std::string &nickName, const std::string &byWhom, const std::string &reason);
|
||||||
|
void SignalLobbyPlayerLeft(unsigned playerId);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|||||||
@@ -66,6 +66,10 @@ public:
|
|||||||
virtual void SignalNetClientServerListClear() =0;
|
virtual void SignalNetClientServerListClear() =0;
|
||||||
virtual void SignalNetClientServerListShow() =0;
|
virtual void SignalNetClientServerListShow() =0;
|
||||||
|
|
||||||
|
virtual void SignalLobbyPlayerJoined(unsigned playerId, const std::string &nickName) = 0;
|
||||||
|
virtual void SignalLobbyPlayerKicked(const std::string &nickName, const std::string &byWhom, const std::string &reason) = 0;
|
||||||
|
virtual void SignalLobbyPlayerLeft(unsigned playerId) = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -730,7 +730,6 @@ AbstractClientStateReceiving::HandlePacket(boost::shared_ptr<ClientThread> clien
|
|||||||
if (netInfo->avatarData != NULL)
|
if (netInfo->avatarData != NULL)
|
||||||
{
|
{
|
||||||
tmpInfo.hasAvatar = true;
|
tmpInfo.hasAvatar = true;
|
||||||
// TODO: use sha1.
|
|
||||||
memcpy(tmpInfo.avatar.data, netInfo->avatarData->avatar.buf, MD5_DATA_SIZE);
|
memcpy(tmpInfo.avatar.data, netInfo->avatarData->avatar.buf, MD5_DATA_SIZE);
|
||||||
tmpInfo.avatarType = (AvatarFileType)netInfo->avatarData->avatarType;
|
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)
|
else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_playerListMessage)
|
||||||
{
|
{
|
||||||
PlayerListMessage_t *netPlayerList = &tmpPacket->GetMsg()->choice.playerListMessage;
|
PlayerListMessage_t *netPlayerList = &tmpPacket->GetMsg()->choice.playerListMessage;
|
||||||
PlayerInfo info;
|
|
||||||
if (!client->GetCachedPlayerInfo(netPlayerList->playerId, info))
|
if (netPlayerList->playerListNotification == playerListNotification_playerListNew)
|
||||||
{
|
{
|
||||||
// Request player info.
|
PlayerInfo info;
|
||||||
client->RequestPlayerInfo(netPlayerList->playerId);
|
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)
|
else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_gameListMessage)
|
||||||
|
|||||||
@@ -263,6 +263,8 @@ ServerLobbyThread::CloseSession(SessionWrapper session)
|
|||||||
m_sessionManager.RemoveSession(session.sessionData->GetId());
|
m_sessionManager.RemoveSession(session.sessionData->GetId());
|
||||||
m_gameSessionManager.RemoveSession(session.sessionData->GetId());
|
m_gameSessionManager.RemoveSession(session.sessionData->GetId());
|
||||||
|
|
||||||
|
if (session.playerData)
|
||||||
|
NotifyPlayerLeftLobby(session.playerData->GetUniqueId());
|
||||||
// Update stats (if needed).
|
// Update stats (if needed).
|
||||||
UpdateStatisticsNumberOfPlayers();
|
UpdateStatisticsNumberOfPlayers();
|
||||||
}
|
}
|
||||||
@@ -274,6 +276,22 @@ ServerLobbyThread::ResubscribeLobbyMsg(SessionWrapper session)
|
|||||||
InternalResubscribeMsg(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
|
void
|
||||||
ServerLobbyThread::NotifyPlayerJoinedGame(unsigned gameId, unsigned playerId)
|
ServerLobbyThread::NotifyPlayerJoinedGame(unsigned gameId, unsigned playerId)
|
||||||
{
|
{
|
||||||
@@ -1129,9 +1147,7 @@ ServerLobbyThread::EstablishSession(SessionWrapper session)
|
|||||||
m_statDataChanged = true;
|
m_statDataChanged = true;
|
||||||
}
|
}
|
||||||
// Notify all players.
|
// Notify all players.
|
||||||
boost::shared_ptr<NetPacket> notify = CreateNetPacketPlayerListNew(session.playerData->GetUniqueId());
|
NotifyPlayerJoinedLobby(session.playerData->GetUniqueId());
|
||||||
m_sessionManager.SendLobbyMsgToAllSessions(GetSender(), notify, SessionData::Established);
|
|
||||||
m_gameSessionManager.SendLobbyMsgToAllSessions(GetSender(), notify, SessionData::Game);
|
|
||||||
|
|
||||||
UpdateStatisticsNumberOfPlayers();
|
UpdateStatisticsNumberOfPlayers();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,6 +62,8 @@ public:
|
|||||||
void RemoveSessionFromGame(SessionWrapper session);
|
void RemoveSessionFromGame(SessionWrapper session);
|
||||||
void SessionError(SessionWrapper session, int errorCode);
|
void SessionError(SessionWrapper session, int errorCode);
|
||||||
void ResubscribeLobbyMsg(SessionWrapper session);
|
void ResubscribeLobbyMsg(SessionWrapper session);
|
||||||
|
void NotifyPlayerJoinedLobby(unsigned playerId);
|
||||||
|
void NotifyPlayerLeftLobby(unsigned playerId);
|
||||||
void NotifyPlayerJoinedGame(unsigned gameId, unsigned playerId);
|
void NotifyPlayerJoinedGame(unsigned gameId, unsigned playerId);
|
||||||
void NotifyPlayerLeftGame(unsigned gameId, unsigned playerId);
|
void NotifyPlayerLeftGame(unsigned gameId, unsigned playerId);
|
||||||
void NotifyGameAdminChanged(unsigned gameId, unsigned newAdminPlayerId);
|
void NotifyGameAdminChanged(unsigned gameId, unsigned newAdminPlayerId);
|
||||||
|
|||||||
Reference in New Issue
Block a user