Use own lobby chat instead of IRC. First steps, still incomplete.

This commit is contained in:
lotodore
2009-08-15 10:25:13 +00:00
parent 94db67bbd5
commit 4c340d5bdc
18 changed files with 104 additions and 93 deletions
+24 -3
View File
@@ -399,14 +399,13 @@ ServerLobbyThread::SendGlobalChat(const string &message)
boost::shared_ptr<NetPacket> packet(new NetPacket(NetPacket::Alloc));
packet->GetMsg()->present = PokerTHMessage_PR_chatMessage;
ChatMessage_t *netChat = &packet->GetMsg()->choice.chatMessage;
// TODO proper game id handling.
netChat->gameId = 0;
netChat->playerId = 0;
netChat->chatType.present = chatType_PR_chatTypeBroadcast;
OCTET_STRING_fromBuf(
&netChat->chatText,
message.c_str(),
message.length());
m_sessionManager.SendToAllSessions(GetSender(), packet, SessionData::Established);
m_gameSessionManager.SendToAllSessions(GetSender(), packet, SessionData::Game);
}
@@ -747,6 +746,8 @@ ServerLobbyThread::HandlePacket(SessionWrapper session, boost::shared_ptr<NetPac
else if (joinRequest->joinGameAction.present == joinGameAction_PR_joinExistingGame)
HandleNetPacketJoinGame(session, password, joinRequest->joinGameAction.choice.joinExistingGame);
}
else if (packet->GetMsg()->present == PokerTHMessage_PR_chatRequestMessage)
HandleNetPacketChatRequest(session, packet->GetMsg()->choice.chatRequestMessage);
else
SessionError(session, ERR_SOCK_INVALID_STATE);
}
@@ -1070,6 +1071,26 @@ ServerLobbyThread::HandleNetPacketJoinGame(SessionWrapper session, const std::st
}
}
void
ServerLobbyThread::HandleNetPacketChatRequest(SessionWrapper session, const ChatRequestMessage_t &chatRequest)
{
if (chatRequest.chatRequestType.present == chatRequestType_PR_chatRequestTypeLobby && session.playerData)
{
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_chatTypeLobby;
ChatTypeLobby_t *netLobbyChat = &netChat->chatType.choice.chatTypeLobby;
netLobbyChat->playerId = session.playerData->GetUniqueId();
OCTET_STRING_fromBuf(
&netChat->chatText,
(char *)chatRequest.chatText.buf,
chatRequest.chatText.size);
m_sessionManager.SendToAllSessions(GetSender(), packet, SessionData::Established);
}
}
void
ServerLobbyThread::EstablishSession(SessionWrapper session)
{