SLikeNet 0.1.3

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
SLNet::CommandParserInterface Class Referenceabstract

The interface used by command parsers. More...

`#include <slikenet/CommandParserInterface.h>`

Inheritance diagram for SLNet::CommandParserInterface:

## Public Member Functions

| CommandParserInterface ()
virtual | ~CommandParserInterface ()
virtual const char * | GetName (void) const =0
virtual void | OnNewIncomingConnection (const SystemAddress &systemAddress, TransportInterface *transport)
| A callback for when systemAddress has connected to us.
virtual void | OnConnectionLost (const SystemAddress &systemAddress, TransportInterface *transport)
| A callback for when systemAddress has disconnected, either gracefully or forcefully.
virtual void | SendHelp (TransportInterface *transport, const SystemAddress &systemAddress)=0
| A callback for when you are expected to send a brief description of your parser to systemAddress.
virtual bool | OnCommand (const char *command, unsigned numParameters, char **parameterList, TransportInterface *transport, const SystemAddress &systemAddress, const char *originalString)=0
| Given command with parameters parameterList , do whatever processing you wish.
virtual void | OnTransportChange (TransportInterface *transport)
| This is called every time transport interface is registered.
virtual bool | GetRegisteredCommand (const char *command, RegisteredCommand *rc)
virtual void | SendCommandList (TransportInterface *transport, const SystemAddress &systemAddress)
virtual void | RegisterCommand (unsigned char parameterCount, const char *command, const char *commandHelp)
virtual void | ReturnResult (bool res, const char *command, TransportInterface *transport, const SystemAddress &systemAddress)
| Just writes a string to the remote system based on the result ( res ) of your operation.
virtual void | ReturnResult (char *res, const char *command, TransportInterface *transport, const SystemAddress &systemAddress)
virtual void | ReturnResult (SystemAddress res, const char *command, TransportInterface *transport, const SystemAddress &systemAddress)
virtual void | ReturnResult (int res, const char *command, TransportInterface *transport, const SystemAddress &systemAddress)
virtual void | ReturnResult (const char *command, TransportInterface *transport, const SystemAddress &systemAddress)
| Just writes a string to the remote system when you are calling a function that has no return value.

## Static Public Member Functions

static void | ParseConsoleString (char *str, const char delineator, unsigned char delineatorToggle, unsigned *numParameters, char **parameterList, unsigned parameterListLength)

## Static Public Attributes

static const unsigned char | VARIABLE_NUMBER_OF_PARAMETERS =255

## Protected Attributes

DataStructures::OrderedList < const char *, RegisteredCommand, RegisteredCommandComp > | commandList

## Detailed Description

The interface used by command parsers.

CommandParserInterface provides a set of functions and interfaces that plug into the ConsoleServer class. Each CommandParserInterface works at the same time as other interfaces in the system.

Definition at line 50 of file CommandParserInterface.h.

## Constructor & Destructor Documentation

CommandParserInterface::CommandParserInterface | ( |  | ) |

Definition at line 46 of file CommandParserInterface.cpp.

CommandParserInterface::~CommandParserInterface | ( |  | ) |

virtual

Definition at line 47 of file CommandParserInterface.cpp.

## Member Function Documentation

virtual const char* SLNet::CommandParserInterface::GetName | ( | void |  | ) | const

pure virtual

You are responsible for overriding this function and returning a static string, which will identifier your parser. This should return a static string

Returns
  The name that you return.

Implemented in SLNet::LogCommandParser, and SLNet::RakNetCommandParser.

bool CommandParserInterface::GetRegisteredCommand | ( | const char * | command,
|  | RegisteredCommand * | rc
| ) |  |

virtual

Definition at line 119 of file CommandParserInterface.cpp.

References commandList, and DataStructures::OrderedList< key_type, data_type, default_comparison_function >::GetIndexFromKey().

virtual bool SLNet::CommandParserInterface::OnCommand | ( | const char * | command,
|  | unsigned | numParameters,
|  | char ** | parameterList,
|  | TransportInterface * | transport,
|  | const SystemAddress & | systemAddress,
|  | const char * | originalString
| ) |  |

pure virtual

Given command with parameters parameterList , do whatever processing you wish.

Parameters

  [in] | command | The command to process
  [in] | numParameters | How many parameters were passed along with the command
  [in] | parameterList | The list of parameters. parameterList[0] is the first parameter and so on.
  [in] | transport | The transport interface we can use to write to
  [in] | systemAddress | The player that sent this command.
  [in] | originalString | The string that was actually sent over the network, in case you want to do your own parsing

Implemented in SLNet::LogCommandParser, and SLNet::RakNetCommandParser.

void CommandParserInterface::OnConnectionLost | ( | const SystemAddress & | systemAddress,
|  | TransportInterface * | transport
| ) |  |

virtual

A callback for when systemAddress has disconnected, either gracefully or forcefully.

Parameters

  [in] | systemAddress | The player that has disconnected.
  [in] | transport | The transport interface that sent us this information.

Reimplemented in SLNet::LogCommandParser.

Definition at line 137 of file CommandParserInterface.cpp.

void CommandParserInterface::OnNewIncomingConnection | ( | const SystemAddress & | systemAddress,
|  | TransportInterface * | transport
| ) |  |

virtual

A callback for when systemAddress has connected to us.

Parameters

  [in] | systemAddress | The player that has connected.
  [in] | transport | The transport interface that sent us this information. Can be used to send messages to this or other players.

Reimplemented in SLNet::LogCommandParser.

Definition at line 132 of file CommandParserInterface.cpp.

void CommandParserInterface::OnTransportChange | ( | TransportInterface * | transport | ) |

virtual

This is called every time transport interface is registered.

If you want to save a copy of the TransportInterface pointer This is the place to do it

Parameters

  [in] | transport | The new TransportInterface

Reimplemented in SLNet::LogCommandParser.

Definition at line 128 of file CommandParserInterface.cpp.

void CommandParserInterface::ParseConsoleString | ( | char * | str,
|  | const char | delineator,
|  | unsigned char | delineatorToggle,
|  | unsigned * | numParameters,
|  | char ** | parameterList,
|  | unsigned | parameterListLength
| ) |  |

static

Definition at line 49 of file CommandParserInterface.cpp.

References RakAssert.

void CommandParserInterface::RegisterCommand | ( | unsigned char | parameterCount,
|  | const char * | command,
|  | const char * | commandHelp
| ) |  |

virtual

Registers a command.

Parameters

  [in] | parameterCount | How many parameters your command requires. If you want to accept a variable number of commands, pass CommandParserInterface::VARIABLE_NUMBER_OF_PARAMETERS
  [in] | command | A pointer to a STATIC string that has your command. I keep a copy of the pointer here so don't deallocate the string.
  [in] | commandHelp | A pointer to a STATIC string that has the help information for your command. I keep a copy of the pointer here so don't deallocate the string.

Definition at line 111 of file CommandParserInterface.cpp.

References _FILE_AND_LINE_, SLNet::RegisteredCommand::command, SLNet::RegisteredCommand::commandHelp, commandList, DataStructures::OrderedList< key_type, data_type, default_comparison_function >::Insert(), and SLNet::RegisteredCommand::parameterCount.

void CommandParserInterface::ReturnResult | ( | bool | res,
|  | const char * | command,
|  | TransportInterface * | transport,
|  | const SystemAddress & | systemAddress
| ) |  |

virtual

Just writes a string to the remote system based on the result ( res ) of your operation.

This is not necessary to call, but makes it easier to return results of function calls.

Parameters

  [in] | res | The result to write
  [in] | command | The command that this result came from
  [in] | transport | The transport interface that will be written to
  [in] | systemAddress | The player this result will be sent to

Definition at line 142 of file CommandParserInterface.cpp.

References SLNet::TransportInterface::Send().

void CommandParserInterface::ReturnResult | ( | char * | res,
|  | const char * | command,
|  | TransportInterface * | transport,
|  | const SystemAddress & | systemAddress
| ) |  |

virtual

Definition at line 157 of file CommandParserInterface.cpp.

References SLNet::TransportInterface::Send().

void CommandParserInterface::ReturnResult | ( | SystemAddress | res,
|  | const char * | command,
|  | TransportInterface * | transport,
|  | const SystemAddress & | systemAddress
| ) |  |

virtual

Definition at line 161 of file CommandParserInterface.cpp.

References SLNet::SystemAddress::GetPort(), SLNet::TransportInterface::Send(), and SLNet::SystemAddress::ToString().

void CommandParserInterface::ReturnResult | ( | int | res,
|  | const char * | command,
|  | TransportInterface * | transport,
|  | const SystemAddress & | systemAddress
| ) |  |

virtual

Definition at line 149 of file CommandParserInterface.cpp.

References SLNet::TransportInterface::Send().

void CommandParserInterface::ReturnResult | ( | const char * | command,
|  | TransportInterface * | transport,
|  | const SystemAddress & | systemAddress
| ) |  |

virtual

Just writes a string to the remote system when you are calling a function that has no return value.

This is not necessary to call, but makes it easier to return results of function calls.

Parameters

  [in] | res | The result to write
  [in] | command | The command that this result came from
  [in] | transport | The transport interface that will be written to
  [in] | systemAddress | The player this result will be sent to

Definition at line 153 of file CommandParserInterface.cpp.

References SLNet::TransportInterface::Send().

void CommandParserInterface::SendCommandList | ( | TransportInterface * | transport,
|  | const SystemAddress & | systemAddress
| ) |  |

virtual

Definition at line 95 of file CommandParserInterface.cpp.

References commandList, SLNet::TransportInterface::Send(), and DataStructures::OrderedList< key_type, data_type, default_comparison_function >::Size().

virtual void SLNet::CommandParserInterface::SendHelp | ( | TransportInterface * | transport,
|  | const SystemAddress & | systemAddress
| ) |  |

pure virtual

A callback for when you are expected to send a brief description of your parser to systemAddress.

Parameters

  [in] | transport | The transport interface we can use to write to
  [in] | systemAddress | The player that requested help.

Implemented in SLNet::LogCommandParser, and SLNet::RakNetCommandParser.

## Member Data Documentation

DataStructures::OrderedList<const char*, RegisteredCommand, RegisteredCommandComp> SLNet::CommandParserInterface::commandList

protected

Definition at line 146 of file CommandParserInterface.h.

Referenced by GetRegisteredCommand(), RegisterCommand(), and SendCommandList().

const unsigned char CommandParserInterface::VARIABLE_NUMBER_OF_PARAMETERS =255

static

Definition at line 114 of file CommandParserInterface.h.

The documentation for this class was generated from the following files:

- Source/include/slikenet/CommandParserInterface.h
- Source/src/CommandParserInterface.cpp