Lobby chat works now, but player list ist not yet shown.
This commit is contained in:
@@ -826,11 +826,9 @@ AbstractClientStateReceiving::HandlePacket(boost::shared_ptr<ClientThread> clien
|
||||
else if (netMessage->chatType.present == chatType_PR_chatTypeLobby)
|
||||
{
|
||||
unsigned playerId = netMessage->chatType.choice.chatTypeLobby.playerId;
|
||||
boost::shared_ptr<PlayerData> tmpPlayer = client->GetPlayerDataByUniqueId(playerId);
|
||||
if (tmpPlayer.get())
|
||||
playerName = tmpPlayer->GetName();
|
||||
if (!playerName.empty())
|
||||
client->GetCallback().SignalNetClientLobbyChatMsg(playerName, STL_STRING_FROM_OCTET_STRING(netMessage->chatText));
|
||||
PlayerInfo info;
|
||||
if (client->GetCachedPlayerInfo(playerId, info))
|
||||
client->GetCallback().SignalNetClientLobbyChatMsg(info.playerName, STL_STRING_FROM_OCTET_STRING(netMessage->chatText));
|
||||
}
|
||||
}
|
||||
else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_dialogMessage)
|
||||
|
||||
@@ -237,18 +237,26 @@ AbstractServerGameStateReceiving::ProcessPacket(boost::shared_ptr<ServerGame> se
|
||||
// Forward chat text to all players.
|
||||
// TODO: Some limitation needed.
|
||||
ChatRequestMessage_t *netChatRequest = &packet->GetMsg()->choice.chatRequestMessage;
|
||||
boost::shared_ptr<NetPacket> packet(new NetPacket(NetPacket::Alloc));
|
||||
packet->GetMsg()->present = PokerTHMessage_PR_chatMessage;
|
||||
ChatMessage_t *netChat = &packet->GetMsg()->choice.chatMessage;
|
||||
netChat->chatType.present = chatType_PR_chatTypeGame;
|
||||
ChatTypeGame_t *netGameChat = &netChat->chatType.choice.chatTypeGame;
|
||||
netGameChat->gameId = server->GetId();
|
||||
netGameChat->playerId = session.playerData->GetUniqueId();
|
||||
OCTET_STRING_fromBuf(
|
||||
&netChat->chatText,
|
||||
(char *)netChatRequest->chatText.buf,
|
||||
netChatRequest->chatText.size);
|
||||
server->SendToAllPlayers(packet, SessionData::Game);
|
||||
if (netChatRequest->chatRequestType.present == chatRequestType_PR_chatRequestTypeLobby)
|
||||
{
|
||||
if (!server->IsRunning())
|
||||
server->GetLobbyThread().HandleChatRequest(session, *netChatRequest);
|
||||
}
|
||||
else if (netChatRequest->chatRequestType.present == chatRequestType_PR_chatRequestTypeGame)
|
||||
{
|
||||
boost::shared_ptr<NetPacket> packet(new NetPacket(NetPacket::Alloc));
|
||||
packet->GetMsg()->present = PokerTHMessage_PR_chatMessage;
|
||||
ChatMessage_t *netChat = &packet->GetMsg()->choice.chatMessage;
|
||||
netChat->chatType.present = chatType_PR_chatTypeGame;
|
||||
ChatTypeGame_t *netGameChat = &netChat->chatType.choice.chatTypeGame;
|
||||
netGameChat->gameId = server->GetId();
|
||||
netGameChat->playerId = session.playerData->GetUniqueId();
|
||||
OCTET_STRING_fromBuf(
|
||||
&netChat->chatText,
|
||||
(char *)netChatRequest->chatText.buf,
|
||||
netChatRequest->chatText.size);
|
||||
server->SendToAllPlayers(packet, SessionData::Game);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (packet->GetMsg()->present == PokerTHMessage_PR_subscriptionRequestMessage)
|
||||
|
||||
@@ -355,6 +355,13 @@ ServerLobbyThread::HandleGameRetrieveAvatar(SessionWrapper session, const Avatar
|
||||
HandleNetPacketRetrieveAvatar(session, retrieveAvatar);
|
||||
}
|
||||
|
||||
void
|
||||
ServerLobbyThread::HandleChatRequest(SessionWrapper session, const ChatRequestMessage_t &chatRequest)
|
||||
{
|
||||
// Someone within a game sent a lobby message.
|
||||
HandleNetPacketChatRequest(session, chatRequest);
|
||||
}
|
||||
|
||||
bool
|
||||
ServerLobbyThread::KickPlayerByName(const std::string &playerName)
|
||||
{
|
||||
@@ -1087,7 +1094,8 @@ ServerLobbyThread::HandleNetPacketChatRequest(SessionWrapper session, const Chat
|
||||
(char *)chatRequest.chatText.buf,
|
||||
chatRequest.chatText.size);
|
||||
|
||||
m_sessionManager.SendToAllSessions(GetSender(), packet, SessionData::Established);
|
||||
m_sessionManager.SendLobbyMsgToAllSessions(GetSender(), packet, SessionData::Established);
|
||||
m_gameSessionManager.SendLobbyMsgToAllSessions(GetSender(), packet, SessionData::Game);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user