$COMMANDHANDLER

From HEWIKI
(Redirected from Technical:Command Handler)
Jump to: navigation, search

$COMMANDHANDLER is a system node which services the command handler system.

Overview

A common element in most MMOs since the age of the MUD is the prevalence of the /command ("slash command") which provides the players and the GameMaster staff with a command-line interface to a variety of capabilities exposed by the developers. This can range anywhere from a simple emote /smile to a complex macroing system for issuing commands in sequence. HeroEngine supports a generic system for registering and handling commands called the CommandHandler which functions via either HeroBlade's Chat Panel, or via your game chat GUI.

The command handler system is used to send strings from client to server and vice versa to be interpreted via script, using a separate pathway from the chat system, to keep the two distinct. Like chat, this system could effectively be replaced by a series of remote calls, but doing that is not as lightweight. This system should not be used to pass extremely complex data as it can only send a single string.

Client

The client side of the command handler system is serviced by the $CommandHandler node. It has one method that is called from C++ when the client receives a command from the server (you can also call the method directly from another client script to "fake" receiving a command).

unique method _ProcessCommand(input as String)

This is overridden by the HE_ProcessCommand method. If it is not overridden, it calls the DefaultProcessCommand method which has some built-in functionality for printing debug information to the console. All of the built-in commands being with an underscore, but you are free to use any prefix (or no prefix) when implementing your own commands.

The client also has an external function, SendCommand(command as string), which is used to send the string to the server for processing. By default, HeroBlade's chat panel interprets any line that starts with a slash ("/") as a message to send via this function rather than as a chat message.

Server

The server has its own $CommandHandler system node which accepts commands coming in from players via

unique method _ProcessCommand(player as NodeRef, input as String)

This will call _isHECommand to see if the command is part of HeroEngine's built-in commands. If it is, a call is made to $PERMISSIONS._isAccountHeroEngineCommandUser to verify that the user is allowed to access the command.

All other commands get routed to commandHQ:Process (by default; this can be overridden by implementing the override method HE_ProcessCommand).

method _isHECommand(command as String) as Boolean

Here is where the list of all built-in HeroEngine commands is defined. If it's not in this list, it isn't a HeroEngine command.

The server also has an external function, SendPlayerCommand(playerNode as ID, commandMessage as String), which sends the command to the client to be interpreted by the client's $CommandHandler._ProcessCommand (as explained above).

commandHQ

This is an optional but very useful system. It is used by default if you do not override $CommandHandler's _ProcessCommand method to not do so. The system implements a prototype which stores a list of all commands you wish to be interpreted via the server's $CommandHandler._ProcessCommand method (i.e. sent from a client via the SendCommand external function). A command is defined mainly by two things: the string to match against and the script to call. The commandHQ system does partial matching, so you don't have to type things out fully. On a match, it calls the specified script at a shared function, allowing the script to take over and do whatever it wants. Manipulating the list of registered commands is done via /REGISTER.

See also

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox