Handles all commands sent by the players on the server.
More...
#include <CommandHandler.h>
Handles all commands sent by the players on the server.
Definition at line 77 of file CommandHandler.h.
◆ CommandHandler()
Constructs a CommandHandler for use by a single server network interface.
Definition at line 39 of file CommandHandler.cpp.
static CommandHandler * Staticaccess
A static access member for command executing functions.
NetworkServerInterface * Owner
Pointer to the owning interface for fetching various other things.
◆ ~CommandHandler()
DLLEXPORT Leviathan::CommandHandler::~CommandHandler |
( |
| ) |
|
|
virtual |
Definition at line 45 of file CommandHandler.cpp.
void _LetGoOfAll()
Lets go of all the CommandSenders.
static CommandHandler * Staticaccess
A static access member for command executing functions.
std::vector< std::shared_ptr< CustomCommandHandler > > CustomHandlers
All the custom command providers.
◆ _AddSender()
void Leviathan::CommandHandler::_AddSender |
( |
CommandSender * |
object | ) |
|
|
protected |
Adds a CommandSender to the list of active ones.
Definition at line 178 of file CommandHandler.cpp.
181 object->StartOwnership(
this);
std::list< CommandSender * > SendersInUse
Holds all the command dispatchers who are currently executing commands.
◆ _LetGoOfAll()
void Leviathan::CommandHandler::_LetGoOfAll |
( |
| ) |
|
|
protected |
Lets go of all the CommandSenders.
Definition at line 149 of file CommandHandler.cpp.
152 for(
auto iter =
SendersInUse.begin(); iter != end; ++iter){
154 (*iter)->EndOwnership(
this);
std::list< CommandSender * > SendersInUse
Holds all the command dispatchers who are currently executing commands.
◆ Get()
Definition at line 57 of file CommandHandler.cpp.
static CommandHandler * Staticaccess
A static access member for command executing functions.
◆ IsSenderStillValid()
Called by an actual command callback to make sure that the sender is still active.
- Parameters
-
retlock | Will contain a lock for the object so hold onto it while using the object |
Definition at line 128 of file CommandHandler.cpp.
132 for(
auto iter =
SendersInUse.begin(); iter != end; ++iter){
133 if(*iter == checkthis){
std::list< CommandSender * > SendersInUse
Holds all the command dispatchers who are currently executing commands.
◆ IsThisDefaultCommand()
DLLEXPORT bool Leviathan::CommandHandler::IsThisDefaultCommand |
( |
const std::string & |
firstword | ) |
const |
|
virtual |
Returns true when the default command handling function can process this.
Definition at line 198 of file CommandHandler.cpp.
◆ QueueCommand()
DLLEXPORT void Leviathan::CommandHandler::QueueCommand |
( |
const std::string & |
command, |
|
|
CommandSender * |
issuer |
|
) |
| |
|
virtual |
Queues a command to be executed.
Definition at line 62 of file CommandHandler.cpp.
69 if(itr.GetCharacter() ==
'/')
73 auto firstword = itr.GetNextCharacterSequence<std::string>(
76 if(!firstword || firstword->empty())
98 if((*iter)->CanHandleCommand(*firstword)){
101 *iter, std::make_shared<std::string>(command), issuer)));
DLLEXPORT void QueueTask(std::shared_ptr< QueuedTask > task)
Adds a task to the queue.
static DLLEXPORT ThreadingManager * Get()
virtual DLLEXPORT bool IsThisDefaultCommand(const std::string &firstword) const
Returns true when the default command handling function can process this.
Iterator class for getting parts of a string.
Encapsulates a function that can later be ran in a free thread.
virtual DLLEXPORT void SendPrivateMessage(const std::string &message)
This should send a message to this entity for them to see what happened when they executed a command...
void RunCustomHandler(std::shared_ptr< CustomCommandHandler > handler, std::shared_ptr< std::string > command, CommandSender *sender)
Runs the thing.
std::vector< std::shared_ptr< CustomCommandHandler > > CustomHandlers
All the custom command providers.
void _AddSender(CommandSender *object)
Adds a CommandSender to the list of active ones.
◆ RegisterCustomCommandHandler()
Registers a new custom command handler.
- Parameters
-
handler | The object to use for handling. The object will be owned by this and will be deleted when it is no longer used |
- See also
- CustomCommandHandler
Definition at line 187 of file CommandHandler.cpp.
std::vector< std::shared_ptr< CustomCommandHandler > > CustomHandlers
All the custom command providers.
◆ RemoveMe()
This should be called by CommandSender subclasses when they are no longer available to remove their commands from the queue.
Definition at line 114 of file CommandHandler.cpp.
118 for(
auto iter =
SendersInUse.begin(); iter != end; ++iter){
std::list< CommandSender * > SendersInUse
Holds all the command dispatchers who are currently executing commands.
◆ SenderNoLongerRequired()
Called by a command handler when a CommandSender is no longer needed.
- Parameters
-
stillgotthis | Is the lock received from IsSenderStillValid |
Definition at line 161 of file CommandHandler.cpp.
165 for(
auto iter =
SendersInUse.begin(); iter != end; ++iter){
167 if(*iter == checkthis){
169 (*iter)->EndOwnership(
this);
std::list< CommandSender * > SendersInUse
Holds all the command dispatchers who are currently executing commands.
◆ UpdateStatus()
DLLEXPORT void Leviathan::CommandHandler::UpdateStatus |
( |
| ) |
|
|
virtual |
Call this periodically to perform cleanup tasks.
and depending on actual implementation the command handling. The default implementation doesn't really need this, but it should still be called
Definition at line 144 of file CommandHandler.cpp.
◆ CustomHandlers
◆ Owner
Pointer to the owning interface for fetching various other things.
Definition at line 145 of file CommandHandler.h.
◆ SendersInUse
std::list<CommandSender*> Leviathan::CommandHandler::SendersInUse |
|
protected |
Holds all the command dispatchers who are currently executing commands.
Definition at line 141 of file CommandHandler.h.
◆ Staticaccess
A static access member for command executing functions.
Definition at line 153 of file CommandHandler.h.
The documentation for this class was generated from the following files: