From: <Jef...@us...> - 2007-10-09 22:04:43
|
Revision: 255 http://libirc.svn.sourceforge.net/libirc/?rev=255&view=rev Author: JeffM2501 Date: 2007-10-09 15:04:39 -0700 (Tue, 09 Oct 2007) Log Message: ----------- call any registered command handlers when we get any IRC commands on the server Modified Paths: -------------- trunk/libirc/include/IRCServer.h trunk/libirc/src/IRCServer.cpp Modified: trunk/libirc/include/IRCServer.h =================================================================== --- trunk/libirc/include/IRCServer.h 2007-10-09 22:03:54 UTC (rev 254) +++ trunk/libirc/include/IRCServer.h 2007-10-09 22:04:39 UTC (rev 255) @@ -114,10 +114,10 @@ // it is recomended that the default ALWAYS be called, as it often sets internal data for other mesages // called when the client receves a command of this type - virtual bool receve ( IRCServer &server, IRCServerConnectedClient *client, std::string &command, BaseIRCCommandInfo &info ){return true;} + virtual bool receve ( IRCServer *server, IRCServerConnectedClient *client, const std::string &command, const BaseIRCCommandInfo &info ){return true;} // called when the user wishes to send a command of this type - virtual bool send ( IRCServer &server, IRCServerConnectedClient *client, std::string &command, BaseIRCCommandInfo &info ){return true;} + virtual bool send ( IRCServer *server, IRCServerConnectedClient *client, const std::string &command, const BaseIRCCommandInfo &info ){return true;} protected: std::string name; @@ -166,6 +166,9 @@ IRCServerChannel *getChannel ( const char *name ); IRCServerChannel *getChannel ( const std::string& name ); + // commands + virtual bool receveCommand ( const std::string &commandName, IRCServerConnectedClient *client, const BaseIRCCommandInfo &info ); + protected: friend class IRCServerConnectedClient; Modified: trunk/libirc/src/IRCServer.cpp =================================================================== --- trunk/libirc/src/IRCServer.cpp 2007-10-09 22:03:54 UTC (rev 254) +++ trunk/libirc/src/IRCServer.cpp 2007-10-09 22:04:39 UTC (rev 255) @@ -445,8 +445,37 @@ void IRCServer::clientIRCCommand ( const BaseIRCCommandInfo &command, IRCServerConnectedClient *client ) { + receveCommand(std::string("ALL"),client,command); + + if (atoi(command.command.c_str()) != 0) + receveCommand( std::string("NUMERIC"),client,command); + + // notify any handlers for this specific command + receveCommand(command.command,client,command); } +bool IRCServer::receveCommand ( const std::string &commandName, IRCServerConnectedClient *client, const BaseIRCCommandInfo &info ) +{ + tmCommandHandlerListMap::iterator itr = userCommandHandlers.find(commandName); + if ( itr != userCommandHandlers.end() ) + { + bool callDefault = false; + for ( unsigned int i = 0; i < (unsigned int) itr->second.size(); i++ ) + { + if ( itr->second[i]->receve(this,client,commandName,info)) + callDefault = true; + } + if (!callDefault) + return true; + } + + tmCommandHandlerMap::iterator defaultIter = defaultCommandHandlers.find(commandName); + if ( defaultIter != defaultCommandHandlers.end() && defaultIter->second ) + return defaultIter->second->receve(this,client,commandName,info); + + return false; +} + void IRCServer::addDefaultCommandHandlers ( IRCServerCommandHandler* handler ) { defaultCommandHandlers[handler->getCommandName()] = handler; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |