Adds the ability to send logging output to a remote console. More...
#include <LogCommandParser.h>
Inherits CommandParserInterface.
Classes | |
struct | SystemAddressAndChannel |
One of these structures is created per player. More... | |
Public Member Functions | |
LogCommandParser () | |
~LogCommandParser () | |
bool | OnCommand (const char *command, unsigned numParameters, char **parameterList, TransportInterface *transport, SystemAddress systemAddress, const char *originalString) |
const char * | GetName (void) const |
void | SendHelp (TransportInterface *transport, SystemAddress systemAddress) |
void | AddChannel (const char *channelName) |
All logs must be associated with a channel. This is a filter so that remote clients only get logs for a system they care about. | |
void | WriteLog (const char *channelName, const char *format,...) |
void | OnNewIncomingConnection (SystemAddress systemAddress, TransportInterface *transport) |
void | OnConnectionLost (SystemAddress systemAddress, TransportInterface *transport) |
void | OnTransportChange (TransportInterface *transport) |
Protected Member Functions | |
void | PrintChannels (SystemAddress systemAddress, TransportInterface *transport) const |
unsigned | Unsubscribe (SystemAddress systemAddress, const char *channelName) |
unsigned | Subscribe (SystemAddress systemAddress, const char *channelName) |
unsigned | GetChannelIndexFromName (const char *channelName) |
Protected Attributes | |
DataStructures::List < SystemAddressAndChannel > | remoteUsers |
The list of remote users. Added to when users subscribe, removed when they disconnect or unsubscribe. | |
const char * | channelNames [32] |
Names of the channels at each bit, or 0 for an unused channel. | |
TransportInterface * | trans |
This is so I can save the current transport provider, solely so I can use it without having the user pass it to Log. |
Adds the ability to send logging output to a remote console.
Definition at line 20 of file LogCommandParser.h.
LogCommandParser::LogCommandParser | ( | ) |
LogCommandParser::~LogCommandParser | ( | ) |
Definition at line 25 of file LogCommandParser.cpp.
void LogCommandParser::AddChannel | ( | const char * | channelName | ) |
All logs must be associated with a channel. This is a filter so that remote clients only get logs for a system they care about.
[in] | channelName | A persistent string naming the channel. Don't deallocate this string. |
Definition at line 96 of file LogCommandParser.cpp.
unsigned LogCommandParser::GetChannelIndexFromName | ( | const char * | channelName | ) | [protected] |
Given the name of a channel, return the index into channelNames where it is located
[in] | channelName | The name of the channel |
Definition at line 251 of file LogCommandParser.cpp.
const char * LogCommandParser::GetName | ( | void | ) | const [virtual] |
You are responsible for overriding this function and returning a static string, which will identifier your parser. This should return a static string
Implements CommandParserInterface.
Definition at line 85 of file LogCommandParser.cpp.
bool LogCommandParser::OnCommand | ( | const char * | command, | |
unsigned | numParameters, | |||
char ** | parameterList, | |||
TransportInterface * | transport, | |||
SystemAddress | systemAddress, | |||
const char * | originalString | |||
) | [virtual] |
Given command with parameters parameterList , do whatever processing you wish.
[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 |
Implements CommandParserInterface.
Definition at line 28 of file LogCommandParser.cpp.
void LogCommandParser::OnConnectionLost | ( | SystemAddress | systemAddress, | |
TransportInterface * | transport | |||
) | [virtual] |
A callback for when systemAddress has disconnected, either gracefully or forcefully
[in] | systemAddress | The player that has disconnected. |
[in] | transport | The transport interface that sent us this information. |
Reimplemented from CommandParserInterface.
Definition at line 185 of file LogCommandParser.cpp.
void LogCommandParser::OnNewIncomingConnection | ( | SystemAddress | systemAddress, | |
TransportInterface * | transport | |||
) | [virtual] |
A callback for when systemAddress has connected to us.
[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 from CommandParserInterface.
Definition at line 180 of file LogCommandParser.cpp.
void LogCommandParser::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
[in] | transport | The new TransportInterface |
Reimplemented from CommandParserInterface.
Definition at line 265 of file LogCommandParser.cpp.
void LogCommandParser::PrintChannels | ( | SystemAddress | systemAddress, | |
TransportInterface * | transport | |||
) | const [protected] |
Sends the currently active channels to the user
[in] | systemAddress | The player to send to |
[in] | transport | The transport interface to use to send the channels |
Definition at line 164 of file LogCommandParser.cpp.
void LogCommandParser::SendHelp | ( | TransportInterface * | transport, | |
SystemAddress | systemAddress | |||
) | [virtual] |
A callback for when you are expected to send a brief description of your parser to systemAddress
[in] | transport | The transport interface we can use to write to |
[in] | systemAddress | The player that requested help. |
Implements CommandParserInterface.
Definition at line 89 of file LogCommandParser.cpp.
unsigned LogCommandParser::Subscribe | ( | SystemAddress | systemAddress, | |
const char * | channelName | |||
) | [protected] |
Subscribe a user to a channel (or to all channels)
[in] | systemAddress | The player to subscribe to |
[in] | channelName | If 0, then subscribe from all channels. Otherwise subscribe to the named channel |
Definition at line 218 of file LogCommandParser.cpp.
unsigned LogCommandParser::Unsubscribe | ( | SystemAddress | systemAddress, | |
const char * | channelName | |||
) | [protected] |
Unsubscribe a user from a channel (or from all channels)
[in] | systemAddress | The player to unsubscribe to |
[in] | channelName | If 0, then unsubscribe from all channels. Otherwise unsubscribe from the named channel |
Definition at line 190 of file LogCommandParser.cpp.
void LogCommandParser::WriteLog | ( | const char * | channelName, | |
const char * | format, | |||
... | ||||
) |
Write a log to a channel. Logs are not buffered, so only remote consoles connected and subscribing at the time you write will get the output.
[in] | format | Same as RAKNET_DEBUG_PRINTF() |
[in] | ... | Same as RAKNET_DEBUG_PRINTF() |
Definition at line 117 of file LogCommandParser.cpp.
const char* LogCommandParser::channelNames[32] [protected] |
Names of the channels at each bit, or 0 for an unused channel.
Definition at line 104 of file LogCommandParser.h.
The list of remote users. Added to when users subscribe, removed when they disconnect or unsubscribe.
Definition at line 101 of file LogCommandParser.h.
TransportInterface* LogCommandParser::trans [protected] |
This is so I can save the current transport provider, solely so I can use it without having the user pass it to Log.
Definition at line 107 of file LogCommandParser.h.