From ee55fb86718729e1ce445b9f674bf8287981cbaf Mon Sep 17 00:00:00 2001 From: Yohann Ferreira Date: Sun, 5 Mar 2006 01:14:15 +0000 Subject: Added the server code to enter and leave a channel. Some minor fix to the state code, and completed the TODO a little for later coding. --- src/connectionhandler.cpp | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'src/connectionhandler.cpp') diff --git a/src/connectionhandler.cpp b/src/connectionhandler.cpp index c7a3d49..a336a84 100644 --- a/src/connectionhandler.cpp +++ b/src/connectionhandler.cpp @@ -323,10 +323,11 @@ void ConnectionHandler::makeUsersLeaveChannel(const short channelId) MessageOut result; result.writeShort(SMSG_QUIT_CHANNEL_RESPONSE); result.writeByte(CHATCNL_OUT_OK); + + const std::vector beingList = + chatChannelManager->getUserListInChannel(channelId); for (NetComputers::iterator i = clients.begin(); i != clients.end();i++) { - const std::vector beingList = - chatChannelManager->getUserListInChannel(channelId); // If the being is in the channel, send it the 'leave now' packet for (std::vector::const_iterator j = beingList.begin(); j != beingList.end(); j++) @@ -338,3 +339,28 @@ void ConnectionHandler::makeUsersLeaveChannel(const short channelId) } } } + +void ConnectionHandler::warnUsersAboutPlayerEventInChat(const short channelId, + const std::string& userName, + const char eventId) +{ + MessageOut result; + result.writeShort(SMSG_UPDATE_CHANNEL_RESPONSE); + result.writeByte(eventId); + result.writeString(userName); + + const std::vector beingList = + chatChannelManager->getUserListInChannel(channelId); + for (NetComputers::iterator i = clients.begin(); i != clients.end();i++) + { + // If the being is in the channel, send it the 'eventId' packet + for (std::vector::const_iterator j = beingList.begin(); + j != beingList.end(); j++) + { + if ((*i)->getCharacter().get() == (*j).get() ) + { + (*i)->send(result.getPacket()); + } + } + } +} -- cgit