summaryrefslogtreecommitdiff
path: root/src/net/tmwserv
diff options
context:
space:
mode:
authorDavid Athay <ko2fan@gmail.com>2009-04-23 17:31:14 +0100
committerDavid Athay <ko2fan@gmail.com>2009-04-23 17:31:14 +0100
commit0d439c39e99dbf1120dce784459176f744f70728 (patch)
treeef9dd8ccd23e3ec3f35ad08b1bbe40ac633cd5ab /src/net/tmwserv
parent0b1079c93c9ec61a0e0c00f8c942e5ef84052c05 (diff)
downloadmana-0d439c39e99dbf1120dce784459176f744f70728.tar.gz
mana-0d439c39e99dbf1120dce784459176f744f70728.tar.bz2
mana-0d439c39e99dbf1120dce784459176f744f70728.tar.xz
mana-0d439c39e99dbf1120dce784459176f744f70728.zip
Added listing all online users
Diffstat (limited to 'src/net/tmwserv')
-rw-r--r--src/net/tmwserv/chathandler.cpp27
-rw-r--r--src/net/tmwserv/chathandler.h27
-rw-r--r--src/net/tmwserv/protocol.h5
3 files changed, 49 insertions, 10 deletions
diff --git a/src/net/tmwserv/chathandler.cpp b/src/net/tmwserv/chathandler.cpp
index e3421e93..41dc7bee 100644
--- a/src/net/tmwserv/chathandler.cpp
+++ b/src/net/tmwserv/chathandler.cpp
@@ -66,6 +66,7 @@ ChatHandler::ChatHandler()
CPMSG_QUIT_CHANNEL_RESPONSE,
CPMSG_LIST_CHANNELUSERS_RESPONSE,
CPMSG_CHANNEL_EVENT,
+ CPMSG_WHO_RESPONSE,
0
};
handledMessages = _messages;
@@ -110,6 +111,11 @@ void ChatHandler::handleMessage(MessageIn &msg)
case CPMSG_CHANNEL_EVENT:
handleChannelEvent(msg);
+ break;
+
+ case CPMSG_WHO_RESPONSE:
+ handleWhoResponse(msg);
+ break;
}
}
@@ -296,6 +302,21 @@ void ChatHandler::handleChannelEvent(MessageIn &msg)
}
}
+void ChatHandler::handleWhoResponse(MessageIn &msg)
+{
+ std::string userNick;
+
+ while(msg.getUnreadLength())
+ {
+ userNick = msg.readString();
+ if (userNick == "")
+ {
+ break;
+ }
+ localChatTab->chatLog(userNick, BY_SERVER);
+ }
+}
+
void ChatHandler::talk(const std::string &text)
{
MessageOut msg(PGMSG_SAY);
@@ -379,4 +400,10 @@ void ChatHandler::kickUser(int channelId, const std::string &name)
Net::ChatServer::connection->send(msg);
}
+void ChatHandler::who()
+{
+ MessageOut msg(PCMSG_WHO);
+ Net::ChatServer::connection->send(msg);
+}
+
} // namespace TmwServ
diff --git a/src/net/tmwserv/chathandler.h b/src/net/tmwserv/chathandler.h
index 05f5243d..bc30de7c 100644
--- a/src/net/tmwserv/chathandler.h
+++ b/src/net/tmwserv/chathandler.h
@@ -31,7 +31,7 @@ class ChatHandler : public MessageHandler, public Net::ChatHandler
{
public:
ChatHandler();
-
+
/**
* Handle the given message appropriately.
*/
@@ -60,52 +60,59 @@ class ChatHandler : public MessageHandler, public Net::ChatHandler
void setUserMode(int channelId, const std::string &name, int mode);
void kickUser(int channelId, const std::string &name);
-
+
+ void who();
+
private:
/**
* Handle chat messages sent from the game server.
*/
void handleGameChatMessage(MessageIn &msg);
-
+
/**
* Handle channel entry responses.
*/
void handleEnterChannelResponse(MessageIn &msg);
-
+
/**
* Handle list channels responses.
*/
void handleListChannelsResponse(MessageIn &msg);
-
+
/**
* Handle private messages.
*/
void handlePrivateMessage(MessageIn &msg);
-
+
/**
* Handle announcements.
*/
void handleAnnouncement(MessageIn &msg);
-
+
/**
* Handle chat messages.
*/
void handleChatMessage(MessageIn &msg);
-
+
/**
* Handle quit channel responses.
*/
void handleQuitChannelResponse(MessageIn &msg);
-
+
/**
* Handle list channel users responses.
*/
void handleListChannelUsersResponse(MessageIn &msg);
-
+
/**
* Handle channel events.
*/
void handleChannelEvent(MessageIn &msg);
+
+ /**
+ * Handle who responses.
+ */
+ void handleWhoResponse(MessageIn &msg);
};
} // namespace TmwServ
diff --git a/src/net/tmwserv/protocol.h b/src/net/tmwserv/protocol.h
index 57926611..fc52bd57 100644
--- a/src/net/tmwserv/protocol.h
+++ b/src/net/tmwserv/protocol.h
@@ -167,6 +167,8 @@ enum {
CPMSG_PARTY_INVITED = 0x03A2, // S name
PCMSG_PARTY_ACCEPT_INVITE = 0x03A5, // S name
CPMSG_PARTY_ACCEPT_INVITE_RESPONSE = 0x03A6, // B error, { S name }
+ PCMSG_PARTY_REJECT_INVITE = 0x03A7, // S name
+ CPMSG_PARTY_REJECTED = 0x03A8, // S name
PCMSG_PARTY_QUIT = 0x03AA, // -
CPMSG_PARTY_QUIT_RESPONSE = 0x03AB, // B error
CPMSG_PARTY_NEW_MEMBER = 0x03B0, // W being id, S name
@@ -180,6 +182,9 @@ enum {
PCMSG_CHAT = 0x0410, // S text, W channel
PCMSG_ANNOUNCE = 0x0411, // S text
PCMSG_PRIVMSG = 0x0412, // S user, S text
+ PCMSG_WHO = 0x0415, // -
+ CPMSG_WHO_RESPONSE = 0x0416, // { S user }
+
// -- Channeling
CPMSG_CHANNEL_EVENT = 0x0430, // W channel, B event, S info
PCMSG_ENTER_CHANNEL = 0x0440, // S channel, S password