Shadowrun: Awakened 29 September 2011 - Build 871
PacketLogger.h
Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 #include "NativeFeatureIncludes.h"
00009 #if _RAKNET_SUPPORT_PacketLogger==1
00010 
00011 #ifndef __PACKET_LOGGER_H
00012 #define __PACKET_LOGGER_H
00013 
00014 #include "RakNetTypes.h"
00015 #include "PluginInterface2.h"
00016 #include "Export.h"
00017 
00018 namespace RakNet
00019 {
00021 class RakPeerInterface;
00022 
00027 
00031 class RAK_DLL_EXPORT PacketLogger : public PluginInterface2
00032 {
00033 public:
00034     // GetInstance() and DestroyInstance(instance*)
00035     STATIC_FACTORY_DECLARATIONS(PacketLogger)
00036 
00037     PacketLogger();
00038     virtual ~PacketLogger();
00039 
00040     // Translate the supplied parameters into an output line - overloaded version that takes a MessageIdentifier
00041     // and translates it into a string (numeric or textual representation based on printId); this calls the
00042     // second version which takes a const char* argument for the messageIdentifier
00043     virtual void FormatLine(char* into, const char* dir, const char* type, unsigned int reliableMessageNumber, unsigned int frame
00044         , unsigned char messageIdentifier, const BitSize_t bitLen, unsigned long long time, const SystemAddress& local, const SystemAddress& remote,
00045         unsigned int splitPacketId, unsigned int splitPacketIndex, unsigned int splitPacketCount, unsigned int orderingIndex);
00046     virtual void FormatLine(char* into, const char* dir, const char* type, unsigned int reliableMessageNumber, unsigned int frame
00047         , const char* idToPrint, const BitSize_t bitLen, unsigned long long time, const SystemAddress& local, const SystemAddress& remote,
00048         unsigned int splitPacketId, unsigned int splitPacketIndex, unsigned int splitPacketCount, unsigned int orderingIndex);
00049 
00051     virtual void OnDirectSocketSend(const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress);
00052     virtual void OnDirectSocketReceive(const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress);
00053     virtual void OnReliabilityLayerPacketError(const char *errorMessage, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress);
00054     virtual void OnInternalPacket(InternalPacket *internalPacket, unsigned frameNumber, SystemAddress remoteSystemAddress, RakNet::TimeMS time, int isSend);
00055     virtual void OnAck(unsigned int messageNumber, SystemAddress remoteSystemAddress, RakNet::TimeMS time);
00056     virtual void OnPushBackPacket(const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress);
00057 
00059     virtual void LogHeader(void);
00060 
00062     virtual void WriteLog(const char *str);
00063 
00064     // Write informational messages
00065     virtual void WriteMiscellaneous(const char *type, const char *msg);
00066 
00067 
00068     // Set to true to print ID_* instead of numbers
00069     virtual void SetPrintID(bool print);
00070     // Print or hide acks (clears up the screen not to print them but is worse for debugging)
00071     virtual void SetPrintAcks(bool print);
00072 
00074     virtual void SetPrefix(const char *_prefix);
00075 
00077     virtual void SetSuffix(const char *_suffix);
00078     static const char* BaseIDTOString(unsigned char Id);
00079 
00081     void SetLogDirectMessages(bool send);
00082 protected:
00083     const char* IDTOString(unsigned char Id);
00084     virtual void AddToLog(const char *str);
00085     // Users should override this
00086     virtual const char* UserIDTOString(unsigned char Id);
00087     void GetLocalTime(char buffer[128]);
00088     bool logDirectMessages;
00089 
00090     bool printId, printAcks;
00091     char prefix[256];
00092     char suffix[256];
00093 };
00094 
00095 } // namespace RakNet
00096 
00097 #endif
00098 
00099 #endif // _RAKNET_SUPPORT_*

Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.

GNU Lesser General Public License 3 Sourceforge.net