Add server feature for clients to receive chats while in lobby

Clients can receive chats while in lobby state by having the shell form
present a HtMessageBox with the chat and the player is it from. This
feature was designed to be used with the moderator whisper command.
This commit is contained in:
Nathan Fulton 2016-08-24 22:51:12 -04:00
parent abb1823956
commit 72566c33bd
9 changed files with 30 additions and 0 deletions

View File

@ -471,6 +471,7 @@ public:
dword cPlayers, dword cGames) = 0;
virtual void OnRemoveRoom(dword roomid) = 0;
virtual void OnUpdateRoom(dword roomid, dword cPlayers, dword cGames) = 0;
virtual void OnReceiveChat(const char *player, const char *chat) = 0;
};
class ITransportCallback {

View File

@ -380,4 +380,9 @@ bool LobbyForm::OnFilterEvent(Event *pevt) {
return false;
}
void LobbyForm::OnReceiveChat(const char *player, const char *chat) {
const char *s = base::Format::ToString("%s: %s", player, chat);
HtMessageBox(kfMbWhiteBorder | kfMbKeepTimersEnabled, player, s);
}
} // namespace wi

View File

@ -69,6 +69,7 @@ private:
dword cPlayers, dword cGames);
virtual void OnRemoveRoom(dword roomid);
virtual void OnUpdateRoom(dword roomid, dword cPlayers, dword cGames);
virtual void OnReceiveChat(const char *player, const char *chat);
// ITransportCallback
virtual void OnStatusUpdate(char *pszStatus);

View File

@ -522,6 +522,12 @@ void XTransport::OnLobbyLurkerCount(dword count) {
}
}
void XTransport::OnLobbyReceiveChat(const char *player, const char *chat) {
if (m_plcb != NULL) {
m_plcb->OnReceiveChat(player, chat);
}
}
dword XTransport::JoinRoom(dword roomid, const char *password,
IRoomCallback *prcb) {
// Synchronously join a room. It may fail.

View File

@ -99,6 +99,7 @@ private:
dword cPlayers, dword cGames);
virtual void OnLobbyRemoveRoom(dword idRoom);
virtual void OnLobbyUpdateRoom(dword idRoom, dword cPlayers, dword cGames);
virtual void OnLobbyReceiveChat(const char *player, const char *chat);
virtual void OnRoomJoinResult(dword result);
virtual void OnRoomAddPlayer(const char *player);
virtual void OnRoomRemovePlayer(dword hint, const char *player);

View File

@ -30,6 +30,7 @@ const byte XMSG_LOBBYREMOVEROOM = 0xa8;
const byte XMSG_LOBBYUPDATEROOM = 0xa9;
const byte XMSG_LOBBYLEAVE = 0xaa;
const byte XMSG_LOBBYLEAVERESULT = 0xab;
const byte XMSG_LOBBYRECEIVECHAT = 0xac;
const byte XMSG_ROOMJOIN = 0xb0;
const byte XMSG_ROOMJOINRESULT = 0xb1;
const byte XMSG_ROOMADDPLAYER = 0xb2;
@ -81,6 +82,7 @@ STARTLABEL(XMsgLabels)
LABEL(XMSG_LOBBYADDROOM)
LABEL(XMSG_LOBBYREMOVEROOM)
LABEL(XMSG_LOBBYUPDATEROOM)
LABEL(XMSG_LOBBYRECEIVECHAT)
LABEL(XMSG_LOBBYLEAVE)
LABEL(XMSG_LOBBYLEAVERESULT)
LABEL(XMSG_ROOMJOIN)

View File

@ -163,6 +163,7 @@ typedef XMsg1<XMSG_LOBBYREMOVEROOM> XMsgLobbyRemoveRoom;
typedef XMsg3<XMSG_LOBBYUPDATEROOM> XMsgLobbyUpdateRoom;
typedef XMsg0<XMSG_LOBBYLEAVE> XMsgLobbyLeave;
typedef XMsg1<XMSG_LOBBYLEAVERESULT> XMsgLobbyLeaveResult;
typedef XMsgS2<XMSG_LOBBYRECEIVECHAT, kcbPlayerName, kcbChatMax> XMsgLobbyReceiveChat;
typedef XMsgDS<XMSG_ROOMJOIN, kcbPassword> XMsgRoomJoin;
typedef XMsg1<XMSG_ROOMJOINRESULT> XMsgRoomJoinResult;
typedef XMsgS1<XMSG_ROOMADDPLAYER, kcbPlayerName> XMsgRoomAddPlayer;

View File

@ -242,6 +242,9 @@ XMsg *XPump::XMsgFromBuffer(base::ByteBuffer& bb, dword cb) {
case XMSG_LOBBYLEAVERESULT:
return XMsgLobbyLeaveResult::FromBuffer(bb, cb);
case XMSG_LOBBYRECEIVECHAT:
return XMsgLobbyReceiveChat::FromBuffer(bb, cb);
case XMSG_ROOMJOIN:
return XMsgRoomJoin::FromBuffer(bb, cb);
@ -498,6 +501,14 @@ void XPump::DispatchXMsg(XMsg *pmsg) {
}
break;
case XMSG_LOBBYRECEIVECHAT:
{
XMsgLobbyReceiveChat *pmsgT = (XMsgLobbyReceiveChat *)pmsg;
// player, chat
notify_->OnLobbyReceiveChat(pmsgT->s0_, pmsgT->s1_);
}
break;
case XMSG_ROOMJOIN:
{
XMsgRoomJoin *pmsgT = (XMsgRoomJoin *)pmsg;

View File

@ -41,6 +41,8 @@ public:
{ Assert(); }
virtual void OnLobbyLeave() { Assert(); }
virtual void OnLobbyLeaveResult(dword result) { Assert(); }
virtual void OnLobbyReceiveChat(const char *player, const char *chat)
{ Assert(); }
virtual void OnRoomJoin(dword roomid, const char *password) { Assert(); }
virtual void OnRoomJoinResult(dword result) { Assert(); }
virtual void OnRoomAddPlayer(const char *player) { Assert(); }