diff options
author | Stefan Dombrowski <stefan@uni-bonn.de> | 2011-06-19 23:00:58 +0200 |
---|---|---|
committer | Stefan Dombrowski <stefan@uni-bonn.de> | 2011-06-19 23:00:58 +0200 |
commit | bb7033e0247ab1d3a526a5d68f9c482f6ff01ba7 (patch) | |
tree | 236c0a9b8c57952f854b2156e9b88c0a6a71d913 /src/chat-server/chathandler.h | |
parent | 5d3104147fd5c3392751b3c3e5cd9644a83335a7 (diff) | |
download | manaserv-bb7033e0247ab1d3a526a5d68f9c482f6ff01ba7.tar.gz manaserv-bb7033e0247ab1d3a526a5d68f9c482f6ff01ba7.tar.bz2 manaserv-bb7033e0247ab1d3a526a5d68f9c482f6ff01ba7.tar.xz manaserv-bb7033e0247ab1d3a526a5d68f9c482f6ff01ba7.zip |
Making party invite functional
* An invite expires after 60 seconds.
* For protection of the server memory each player can invite a
maximum of 10 characters within the 60 second timeframe.
Reviewed-by: Bjorn
Diffstat (limited to 'src/chat-server/chathandler.h')
-rw-r--r-- | src/chat-server/chathandler.h | 49 |
1 files changed, 22 insertions, 27 deletions
diff --git a/src/chat-server/chathandler.h b/src/chat-server/chathandler.h index c969a9ae..9796bf78 100644 --- a/src/chat-server/chathandler.h +++ b/src/chat-server/chathandler.h @@ -21,9 +21,9 @@ #ifndef CHATHANDLER_H #define CHATHANDLER_H +#include <deque> #include <map> #include <string> -#include <vector> #include "net/connectionhandler.h" #include "utils/tokencollector.h" @@ -53,13 +53,22 @@ class ChatHandler : public ConnectionHandler struct PartyInvite { + PartyInvite(std::string inviterName, std::string inviteeName) + : mInviter(inviterName) + , mInvitee(inviteeName) + { + const int validTimeframe = 60; + mExpireTime = time(NULL) + validTimeframe; + } + std::string mInviter; - std::string mInvited; - int mPartyId; + std::string mInvitee; + time_t mExpireTime; }; std::map<std::string, ChatClient*> mPlayerMap; - std::vector<PartyInvite> mPartyInvitedUsers; + std::deque<PartyInvite> mInvitations; + std::map<std::string, int> mNumInvites; public: ChatHandler(); @@ -103,6 +112,13 @@ class ChatHandler : public ConnectionHandler void handlePartyInvite(MessageIn &msg); + /** + * Returns ChatClient from the Player Map + * @param The name of the character + * @return The Chat Client + */ + ChatClient *getClient(const std::string &name) const; + protected: /** * Process chat related messages. @@ -164,18 +180,9 @@ class ChatHandler : public ConnectionHandler void handleGuildKickMember(ChatClient &client, MessageIn &msg); void handleGuildQuit(ChatClient &client, MessageIn &msg); - void handlePartyAcceptInvite(ChatClient &client, MessageIn &msg); + void handlePartyInviteAnswer(ChatClient &client, MessageIn &msg); void handlePartyQuit(ChatClient &client); - // TODO: Merge with handlePartyAcceptInvite? - void handlePartyRejectInvite(ChatClient &client, MessageIn &msg); - - /** - * Deal with a player joining a party. - * @return Whether player successfully joined the party - */ - bool handlePartyJoin(const std::string &invited, - const std::string &inviter); - + void removeExpiredPartyInvites(); void removeUserFromParty(ChatClient &client); /** @@ -184,11 +191,6 @@ class ChatHandler : public ConnectionHandler void informPartyMemberQuit(ChatClient &client); /** - * Tell all the party members a member has joined - */ - void informPartyMemberJoined(ChatClient &client); - - /** * Tell the player to be more polite. */ void warnPlayerAboutBadWords(ChatClient &computer); @@ -218,13 +220,6 @@ class ChatHandler : public ConnectionHandler ChatClient &client); /** - * Returns ChatClient from the Player Map - * @param The name of the character - * @return The Chat Client - */ - ChatClient *getClient(const std::string &name) const; - - /** * Set the topic of a guild channel */ void guildChannelTopicChange(ChatChannel *channel, int playerId, |