diff --git a/src/gui/generic/serverguiwrapper.cpp b/src/gui/generic/serverguiwrapper.cpp index 8ca4c704..a0191f6d 100644 --- a/src/gui/generic/serverguiwrapper.cpp +++ b/src/gui/generic/serverguiwrapper.cpp @@ -141,7 +141,8 @@ void ServerGuiWrapper::SignalNetClientGameListUpdateAdmin(unsigned gameId, unsig void ServerGuiWrapper::SignalNetClientGameListPlayerJoined(unsigned gameId, unsigned playerId) { if (myClientcb) myClientcb->SignalNetClientGameListPlayerJoined(gameId, playerId); } void ServerGuiWrapper::SignalNetClientGameListPlayerLeft(unsigned gameId, unsigned playerId) { if (myClientcb) myClientcb->SignalNetClientGameListPlayerLeft(gameId, playerId); } void ServerGuiWrapper::SignalNetClientGameStart(boost::shared_ptr game) { if (myClientcb) myClientcb->SignalNetClientGameStart(game); } -void ServerGuiWrapper::SignalNetClientChatMsg(const string &playerName, const string &msg) { if (myClientcb) myClientcb->SignalNetClientChatMsg(playerName, msg); } +void ServerGuiWrapper::SignalNetClientGameChatMsg(const string &playerName, const string &msg) { if (myClientcb) myClientcb->SignalNetClientGameChatMsg(playerName, msg); } +void ServerGuiWrapper::SignalNetClientLobbyChatMsg(const string &playerName, const string &msg) { if (myClientcb) myClientcb->SignalNetClientLobbyChatMsg(playerName, msg); } void ServerGuiWrapper::SignalNetClientMsgBox(const string &msg) { if (myClientcb) myClientcb->SignalNetClientMsgBox(msg); } void ServerGuiWrapper::SignalNetClientWaitDialog() { if (myClientcb) myClientcb->SignalNetClientWaitDialog(); } diff --git a/src/gui/generic/serverguiwrapper.h b/src/gui/generic/serverguiwrapper.h index 2c0629ce..e6262ca8 100644 --- a/src/gui/generic/serverguiwrapper.h +++ b/src/gui/generic/serverguiwrapper.h @@ -116,7 +116,8 @@ public: void SignalNetClientPlayerChanged(unsigned playerId, const std::string &newPlayerName); void SignalNetClientPlayerLeft(unsigned playerId, const std::string &playerName, int removeReason); void SignalNetClientNewGameAdmin(unsigned playerId, const std::string &playerName); - void SignalNetClientChatMsg(const std::string &playerName, const std::string &msg); + void SignalNetClientGameChatMsg(const std::string &playerName, const std::string &msg); + void SignalNetClientLobbyChatMsg(const std::string &playerName, const std::string &msg); void SignalNetClientWaitDialog(); void SignalNetClientGameListNew(unsigned gameId); diff --git a/src/gui/qt/chattools/chattools.cpp b/src/gui/qt/chattools/chattools.cpp index 5da81682..755fe303 100644 --- a/src/gui/qt/chattools/chattools.cpp +++ b/src/gui/qt/chattools/chattools.cpp @@ -40,7 +40,7 @@ void ChatTools::sendMessage() { fillChatLinesHistory(myLineEdit->text()); if(mySession) { - mySession->sendChatMessage(myLineEdit->text().toUtf8().constData()); + mySession->sendGameChatMessage(myLineEdit->text().toUtf8().constData()); myLineEdit->setText(""); } else { cout << "Session is not valid" << endl;} diff --git a/src/gui/qt/gamelobbydialog/lobbychat/lobbychat.cpp b/src/gui/qt/gamelobbydialog/lobbychat/lobbychat.cpp index 5e0be449..08ae729d 100644 --- a/src/gui/qt/gamelobbydialog/lobbychat/lobbychat.cpp +++ b/src/gui/qt/gamelobbydialog/lobbychat/lobbychat.cpp @@ -42,13 +42,16 @@ LobbyChat::~LobbyChat() void LobbyChat::sendMessage() { - if (myNick.size()) + if (myNick.isEmpty()) + myNick = QString::fromUtf8(myConfig->readConfigString("MyName").c_str()); + + if (!myNick.isEmpty()) { fillChatLinesHistory(myLobby->lineEdit_ChatInput->text()); QString tmpMsg(myLobby->lineEdit_ChatInput->text()); if (tmpMsg.size()) { - myLobby->getSession()->sendIrcChatMessage(tmpMsg.toUtf8().constData()); + myLobby->getSession()->sendLobbyChatMessage(tmpMsg.toUtf8().constData()); myLobby->lineEdit_ChatInput->setText(""); displayMessage(myNick, tmpMsg); @@ -145,8 +148,6 @@ void LobbyChat::clearChat() { myNick = ""; myLobby->treeWidget_NickList->clear(); myLobby->textBrowser_ChatDisplay->clear(); - myLobby->textBrowser_ChatDisplay->append(tr("Connecting to Chat server...")); - myLobby->lineEdit_ChatInput->setEnabled(false); } void LobbyChat::chatError(int errorCode) diff --git a/src/gui/qt/gametable/chat/chat.cpp b/src/gui/qt/gametable/chat/chat.cpp index e0df3757..9833b556 100755 --- a/src/gui/qt/gametable/chat/chat.cpp +++ b/src/gui/qt/gametable/chat/chat.cpp @@ -67,7 +67,7 @@ void Chat::sendMessage() { } fillChatLinesHistory(myW->lineEdit_ChatInput->text()); - myW->getSession()->sendChatMessage(myW->lineEdit_ChatInput->text().toUtf8().constData()); + myW->getSession()->sendGameChatMessage(myW->lineEdit_ChatInput->text().toUtf8().constData()); myW->lineEdit_ChatInput->setText(""); } diff --git a/src/gui/qt/guiwrapper.cpp b/src/gui/qt/guiwrapper.cpp index fe3e60fb..89e6820f 100644 --- a/src/gui/qt/guiwrapper.cpp +++ b/src/gui/qt/guiwrapper.cpp @@ -165,7 +165,8 @@ void GuiWrapper::SignalNetClientGameListPlayerLeft(unsigned gameId, unsigned pla void GuiWrapper::SignalNetClientGameStart(boost::shared_ptr game) { myStartWindow->signalNetClientGameStart(game); } void GuiWrapper::SignalNetClientWaitDialog() { myStartWindow->signalShowClientDialog(); } -void GuiWrapper::SignalNetClientChatMsg(const string &playerName, const string &msg) { myStartWindow->signalNetClientChatMsg(QString::fromUtf8(playerName.c_str()), QString::fromUtf8(msg.c_str())); } +void GuiWrapper::SignalNetClientGameChatMsg(const string &playerName, const string &msg) { myStartWindow->signalNetClientGameChatMsg(QString::fromUtf8(playerName.c_str()), QString::fromUtf8(msg.c_str())); } +void GuiWrapper::SignalNetClientLobbyChatMsg(const string &playerName, const string &msg) { myStartWindow->signalNetClientLobbyChatMsg(QString::fromUtf8(playerName.c_str()), QString::fromUtf8(msg.c_str())); } void GuiWrapper::SignalNetClientMsgBox(const string &msg) { myStartWindow->signalNetClientMsgBox(QString::fromUtf8(msg.c_str())); } void GuiWrapper::SignalNetServerSuccess(int /*actionID*/) { } diff --git a/src/gui/qt/guiwrapper.h b/src/gui/qt/guiwrapper.h index 4aebbeaa..de622a93 100644 --- a/src/gui/qt/guiwrapper.h +++ b/src/gui/qt/guiwrapper.h @@ -127,7 +127,8 @@ public: void SignalNetClientPlayerChanged(unsigned playerId, const std::string &newPlayerName); void SignalNetClientPlayerLeft(unsigned playerId, const std::string &playerName, int removeReason); void SignalNetClientNewGameAdmin(unsigned playerId, const std::string &playerName); - void SignalNetClientChatMsg(const std::string &playerName, const std::string &msg); + void SignalNetClientGameChatMsg(const std::string &playerName, const std::string &msg); + void SignalNetClientLobbyChatMsg(const std::string &playerName, const std::string &msg); void SignalNetClientMsgBox(const std::string &msg); void SignalNetClientWaitDialog(); diff --git a/src/gui/qt/startwindow/startwindowimpl.cpp b/src/gui/qt/startwindow/startwindowimpl.cpp index e5824c53..843ebf68 100644 --- a/src/gui/qt/startwindow/startwindowimpl.cpp +++ b/src/gui/qt/startwindow/startwindowimpl.cpp @@ -141,8 +141,9 @@ startWindowImpl::startWindowImpl(ConfigFile *c) connect(this, SIGNAL(signalNetClientRemovedFromGame(int)), myGameLobbyDialog, SLOT(removedFromGame(int))); connect(this, SIGNAL(signalNetClientStatsUpdate(ServerStats)), myGameLobbyDialog, SLOT(updateStats(ServerStats))); - connect(this, SIGNAL(signalNetClientChatMsg(QString, QString)), myStartNetworkGameDialog, SLOT(receiveChatMsg(QString, QString))); - connect(this, SIGNAL(signalNetClientChatMsg(QString, QString)), myGuiInterface->getMyW()->getMyChat(), SLOT(receiveMessage(QString, QString))); + connect(this, SIGNAL(signalNetClientGameChatMsg(QString, QString)), myStartNetworkGameDialog, SLOT(receiveChatMsg(QString, QString))); + connect(this, SIGNAL(signalNetClientGameChatMsg(QString, QString)), myGuiInterface->getMyW()->getMyChat(), SLOT(receiveMessage(QString, QString))); + connect(this, SIGNAL(signalNetClientLobbyChatMsg(QString, QString)), myGameLobbyDialog->getLobbyChat(), SLOT(displayMessage(QString, QString))); connect(this, SIGNAL(signalNetClientMsgBox(QString)), this, SLOT(networkMessage(QString))); connect(this, SIGNAL(signalNetClientShowTimeoutDialog(int, unsigned)), this, SLOT(showTimeoutDialog(int, unsigned))); @@ -316,35 +317,6 @@ void startWindowImpl::joinGameLobby() { // Clear Lobby dialog. myGameLobbyDialog->clearDialog(); - //set clean irc nick - QString myNick(QString::fromUtf8(myConfig->readConfigString("MyName").c_str())); - myNick.replace(QString::fromUtf8("ä"),"ae"); - myNick.replace(QString::fromUtf8("Ä"),"Ae"); - myNick.replace(QString::fromUtf8("ü"),"ue"); - myNick.replace(QString::fromUtf8("Ü"),"Ue"); - myNick.replace(QString::fromUtf8("ö"),"oe"); - myNick.replace(QString::fromUtf8("Ö"),"Oe"); - myNick.replace(QString::fromUtf8("é"),"e"); - myNick.replace(QString::fromUtf8("è"),"e"); - myNick.replace(QString::fromUtf8("á"),"a"); - myNick.replace(QString::fromUtf8("à"),"a"); - myNick.replace(QString::fromUtf8("ó"),"o"); - myNick.replace(QString::fromUtf8("ò"),"o"); - myNick.replace(QString::fromUtf8("ú"),"u"); - myNick.replace(QString::fromUtf8("ù"),"u"); - myNick.replace(QString::fromUtf8("É"),"E"); - myNick.replace(QString::fromUtf8("È"),"E"); - myNick.replace(QString::fromUtf8("Á"),"A"); - myNick.replace(QString::fromUtf8("À"),"A"); - myNick.replace(QString::fromUtf8("Ó"),"O"); - myNick.replace(QString::fromUtf8("Ò"),"O"); - myNick.replace(QString::fromUtf8("Ú"),"U"); - myNick.replace(QString::fromUtf8("Ù"),"U"); - myNick.remove(QRegExp("[^A-Z^a-z^0-9|\\-_\\\\^`]*")); - myNick = myNick.mid(0,16); - - mySession->setIrcNick(myNick.toUtf8().constData()); - // Start client for dedicated server. mySession->startInternetClient(); diff --git a/src/gui/qt/startwindow/startwindowimpl.h b/src/gui/qt/startwindow/startwindowimpl.h index 384f6ebf..1a28fcb4 100644 --- a/src/gui/qt/startwindow/startwindowimpl.h +++ b/src/gui/qt/startwindow/startwindowimpl.h @@ -80,7 +80,8 @@ signals: void signalNetClientGameListPlayerJoined(unsigned gameId, unsigned playerId); void signalNetClientGameListPlayerLeft(unsigned gameId, unsigned playerId); void signalNetClientGameStart(boost::shared_ptr game); - void signalNetClientChatMsg(QString nickName, QString msg); + void signalNetClientGameChatMsg(QString nickName, QString msg); + void signalNetClientLobbyChatMsg(QString nickName, QString msg); void signalNetClientMsgBox(QString msg); void signalIrcConnect(QString server); diff --git a/src/net/clientcallback.h b/src/net/clientcallback.h index dce1d8ff..4f5485a8 100644 --- a/src/net/clientcallback.h +++ b/src/net/clientcallback.h @@ -57,7 +57,8 @@ public: virtual void SignalNetClientPlayerLeft(unsigned playerId, const std::string &playerName, int removeReason) = 0; virtual void SignalNetClientNewGameAdmin(unsigned playerId, const std::string &playerName) = 0; - virtual void SignalNetClientChatMsg(const std::string &playerName, const std::string &msg) = 0; + virtual void SignalNetClientGameChatMsg(const std::string &playerName, const std::string &msg) = 0; + virtual void SignalNetClientLobbyChatMsg(const std::string &playerName, const std::string &msg) = 0; virtual void SignalNetClientMsgBox(const std::string &msg) = 0; virtual void SignalNetClientWaitDialog() = 0; diff --git a/src/net/clientthread.h b/src/net/clientthread.h index c6f3e7b4..885badb0 100644 --- a/src/net/clientthread.h +++ b/src/net/clientthread.h @@ -70,7 +70,8 @@ public: void SendLeaveCurrentGame(); void SendStartEvent(bool fillUpWithCpuPlayers); void SendPlayerAction(); - void SendChatMessage(const std::string &msg); + void SendGameChatMessage(const std::string &msg); + void SendLobbyChatMessage(const std::string &msg); void SendJoinFirstGame(const std::string &password); void SendJoinGame(unsigned gameId, const std::string &password); void SendCreateGame(const GameData &gameData, const std::string &name, const std::string &password); diff --git a/src/net/common/clientstate.cpp b/src/net/common/clientstate.cpp index 48af75d4..7ec727f7 100644 --- a/src/net/common/clientstate.cpp +++ b/src/net/common/clientstate.cpp @@ -809,18 +809,29 @@ AbstractClientStateReceiving::HandlePacket(boost::shared_ptr clien ChatMessage_t *netMessage = &tmpPacket->GetMsg()->choice.chatMessage; string playerName; - if (netMessage->playerId == 0) + if (netMessage->chatType.present == chatType_PR_chatTypeBroadcast) { - playerName = "(global notice)"; + client->GetCallback().SignalNetClientGameChatMsg("(global notice)", STL_STRING_FROM_OCTET_STRING(netMessage->chatText)); + client->GetCallback().SignalNetClientLobbyChatMsg("(global notice)", STL_STRING_FROM_OCTET_STRING(netMessage->chatText)); } - else + else if (netMessage->chatType.present == chatType_PR_chatTypeGame) { - boost::shared_ptr tmpPlayer = client->GetPlayerDataByUniqueId(netMessage->playerId); + unsigned playerId = netMessage->chatType.choice.chatTypeGame.playerId; + boost::shared_ptr tmpPlayer = client->GetPlayerDataByUniqueId(playerId); if (tmpPlayer.get()) playerName = tmpPlayer->GetName(); + if (!playerName.empty()) + client->GetCallback().SignalNetClientGameChatMsg(playerName, STL_STRING_FROM_OCTET_STRING(netMessage->chatText)); + } + else if (netMessage->chatType.present == chatType_PR_chatTypeLobby) + { + unsigned playerId = netMessage->chatType.choice.chatTypeLobby.playerId; + boost::shared_ptr tmpPlayer = client->GetPlayerDataByUniqueId(playerId); + if (tmpPlayer.get()) + playerName = tmpPlayer->GetName(); + if (!playerName.empty()) + client->GetCallback().SignalNetClientLobbyChatMsg(playerName, STL_STRING_FROM_OCTET_STRING(netMessage->chatText)); } - if (!playerName.empty()) - client->GetCallback().SignalNetClientChatMsg(playerName, STL_STRING_FROM_OCTET_STRING(netMessage->chatText)); } else if (tmpPacket->GetMsg()->present == PokerTHMessage_PR_dialogMessage) { diff --git a/src/net/common/clientthread.cpp b/src/net/common/clientthread.cpp index 3796c254..6a81e4a0 100644 --- a/src/net/common/clientthread.cpp +++ b/src/net/common/clientthread.cpp @@ -172,18 +172,38 @@ ClientThread::SendPlayerAction() } void -ClientThread::SendChatMessage(const std::string &msg) +ClientThread::SendGameChatMessage(const std::string &msg) { // Warning: This function is called in the context of the GUI thread. // Create a network packet containing the chat message. boost::shared_ptr packet(new NetPacket(NetPacket::Alloc)); packet->GetMsg()->present = PokerTHMessage_PR_chatRequestMessage; ChatRequestMessage_t *netChat = &packet->GetMsg()->choice.chatRequestMessage; - netChat->gameId = GetGameId(); OCTET_STRING_fromBuf(&netChat->chatText, msg.c_str(), msg.length()); + netChat->chatRequestType.present = chatRequestType_PR_chatRequestTypeGame; + netChat->chatRequestType.choice.chatRequestTypeGame.gameId = GetGameId(); + + // Just dump the packet. + m_ioService->post(boost::bind(&ClientThread::SendSessionPacket, shared_from_this(), packet)); +} + +void +ClientThread::SendLobbyChatMessage(const std::string &msg) +{ + // Warning: This function is called in the context of the GUI thread. + // Create a network packet containing the chat message. + boost::shared_ptr packet(new NetPacket(NetPacket::Alloc)); + packet->GetMsg()->present = PokerTHMessage_PR_chatRequestMessage; + ChatRequestMessage_t *netChat = &packet->GetMsg()->choice.chatRequestMessage; + OCTET_STRING_fromBuf(&netChat->chatText, + msg.c_str(), + msg.length()); + + netChat->chatRequestType.present = chatRequestType_PR_chatRequestTypeLobby; + // Just dump the packet. m_ioService->post(boost::bind(&ClientThread::SendSessionPacket, shared_from_this(), packet)); } diff --git a/src/net/common/servergamestate.cpp b/src/net/common/servergamestate.cpp index 2319c5cc..8fb66476 100644 --- a/src/net/common/servergamestate.cpp +++ b/src/net/common/servergamestate.cpp @@ -240,8 +240,10 @@ AbstractServerGameStateReceiving::ProcessPacket(boost::shared_ptr se boost::shared_ptr packet(new NetPacket(NetPacket::Alloc)); packet->GetMsg()->present = PokerTHMessage_PR_chatMessage; ChatMessage_t *netChat = &packet->GetMsg()->choice.chatMessage; - netChat->gameId = server->GetId(); - netChat->playerId = session.playerData->GetUniqueId(); + 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, diff --git a/src/net/common/serverlobbythread.cpp b/src/net/common/serverlobbythread.cpp index 24facd4a..99d8974c 100644 --- a/src/net/common/serverlobbythread.cpp +++ b/src/net/common/serverlobbythread.cpp @@ -399,14 +399,13 @@ ServerLobbyThread::SendGlobalChat(const string &message) boost::shared_ptr 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_ptrjoinGameAction.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 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) { diff --git a/src/net/serverlobbythread.h b/src/net/serverlobbythread.h index 8fbeb794..5de948fb 100644 --- a/src/net/serverlobbythread.h +++ b/src/net/serverlobbythread.h @@ -122,6 +122,7 @@ protected: void HandleNetPacketRetrieveAvatar(SessionWrapper session, const AvatarRequestMessage_t &retrieveAvatar); void HandleNetPacketCreateGame(SessionWrapper session, const std::string &password, const JoinNewGame_t &newGame); void HandleNetPacketJoinGame(SessionWrapper session, const std::string &password, const JoinExistingGame_t &joinGame); + void HandleNetPacketChatRequest(SessionWrapper session, const ChatRequestMessage_t &chatRequest); void EstablishSession(SessionWrapper session); void RequestPlayerAvatar(SessionWrapper session); void TimerRemoveGame(const boost::system::error_code &ec); diff --git a/src/session.cpp b/src/session.cpp index 29e9a89f..c125af37 100755 --- a/src/session.cpp +++ b/src/session.cpp @@ -156,30 +156,13 @@ boost::shared_ptr Session::getAvatarManager() void Session::startInternetClient() { - if (myNetClient || myClientIrcThread || !myGui) + if (myNetClient || !myGui) { assert(false); return; } myGameType = GAME_TYPE_INTERNET; - if (myConfig->readConfigInt("UseIRCLobbyChat")) - { - myClientIrcThread.reset(new IrcThread(myGui)); - myClientIrcThread->Init( - myConfig->readConfigString("IRCServerAddress"), - myConfig->readConfigInt("IRCServerPort"), - myConfig->readConfigInt("IRCServerUseIpv6") == 1, - myIrcNick, -#ifdef POKERTH_IS_07BETA - "#pokerth-lobby-07beta", -#else - myConfig->readConfigString("IRCChannel"), -#endif - myConfig->readConfigString("IRCChannelPassword")); - myClientIrcThread->Run(); - } - myNetClient.reset(new ClientThread(*myGui, *myAvatarManager)); bool useAvatarServer = myConfig->readConfigInt("UseAvatarServer") != 0; @@ -261,13 +244,9 @@ void Session::terminateNetworkClient() if (!myNetClient) return; // already terminated myNetClient->SignalTermination(); - if (myClientIrcThread) - myClientIrcThread->SignalTermination(); // Give the threads some time to terminate. if (myNetClient->Join(NET_CLIENT_TERMINATE_TIMEOUT_MSEC)) myNetClient.reset(); - if (myClientIrcThread && myClientIrcThread->Join(NET_IRC_TERMINATE_TIMEOUT_MSEC)) - myClientIrcThread.reset(); // If termination fails, leave a memory leak to prevent a crash. myGameType = GAME_TYPE_NONE; @@ -348,13 +327,6 @@ bool Session::pollNetworkServerTerminated() return retVal; } -void Session::sendIrcChatMessage(const std::string &message) -{ - if (!myClientIrcThread) - return; - myClientIrcThread->SendChatMessage(message); -} - void Session::sendLeaveCurrentGame() { if (!myNetClient) @@ -376,11 +348,18 @@ void Session::sendClientPlayerAction() myNetClient->SendPlayerAction(); } -void Session::sendChatMessage(const std::string &message) +void Session::sendGameChatMessage(const std::string &message) { if (!myNetClient) return; // only act if client is running. - myNetClient->SendChatMessage(message); + myNetClient->SendGameChatMessage(message); +} + +void Session::sendLobbyChatMessage(const std::string &message) +{ + if (!myNetClient) + return; + myNetClient->SendLobbyChatMessage(message); } void Session::kickPlayer(unsigned playerId) diff --git a/src/session.h b/src/session.h index 9767810a..f47d662e 100755 --- a/src/session.h +++ b/src/session.h @@ -75,12 +75,10 @@ public: void terminateNetworkServer(); bool pollNetworkServerTerminated(); - void sendIrcChatMessage(const std::string &message); - void setIrcNick(const std::string &value) { myIrcNick = value; } - void sendClientPlayerAction(); - void sendChatMessage(const std::string &message); + void sendGameChatMessage(const std::string &message); + void sendLobbyChatMessage(const std::string &message); void kickPlayer(unsigned playerId); void kickPlayer(const std::string &playerName); void startVoteKickPlayer(unsigned playerId); @@ -108,7 +106,6 @@ private: boost::shared_ptr myNetClient; boost::shared_ptr myNetServer; - boost::shared_ptr myClientIrcThread; boost::shared_ptr myAvatarManager;