Shadowrun: Awakened 29 September 2011 - Build 871
PluginInterface2.h
Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 #ifndef __PLUGIN_INTERFACE_2_H
00010 #define __PLUGIN_INTERFACE_2_H
00011 
00012 #include "NativeFeatureIncludes.h"
00013 #include "RakNetTypes.h"
00014 #include "Export.h"
00015 #include "PacketPriority.h"
00016 
00017 namespace RakNet {
00018 
00020 class RakPeerInterface;
00021 class PacketizedTCP;
00022 struct Packet;
00023 struct InternalPacket;
00024 
00026 
00029 
00032 enum PluginReceiveResult
00033 {
00035     RR_STOP_PROCESSING_AND_DEALLOCATE=0,
00036 
00038     RR_CONTINUE_PROCESSING,
00039 
00041     RR_STOP_PROCESSING,
00042 };
00043 
00046 enum PI2_LostConnectionReason
00047 {
00049     LCR_CLOSED_BY_USER,
00050 
00052     LCR_DISCONNECTION_NOTIFICATION,
00053 
00055     LCR_CONNECTION_LOST
00056 };
00057 
00060 enum PI2_FailedConnectionAttemptReason
00061 {
00062     FCAR_CONNECTION_ATTEMPT_FAILED,
00063     FCAR_ALREADY_CONNECTED,
00064     FCAR_NO_FREE_INCOMING_CONNECTIONS,
00065     FCAR_SECURITY_PUBLIC_KEY_MISMATCH,
00066     FCAR_CONNECTION_BANNED,
00067     FCAR_INVALID_PASSWORD,
00068     FCAR_INCOMPATIBLE_PROTOCOL,
00069     FCAR_IP_RECENTLY_CONNECTED,
00070     FCAR_REMOTE_SYSTEM_REQUIRES_PUBLIC_KEY,
00071     FCAR_OUR_SYSTEM_REQUIRES_SECURITY,
00072     FCAR_PUBLIC_KEY_MISMATCH,
00073 };
00074 
00082 class RAK_DLL_EXPORT PluginInterface2
00083 {
00084 public:
00085     PluginInterface2();
00086     virtual ~PluginInterface2();
00087 
00089     virtual void OnAttach(void) {}
00090 
00092     virtual void OnDetach(void) {}
00093 
00095     virtual void Update(void) {}
00096 
00100     virtual PluginReceiveResult OnReceive(Packet *packet) {(void) packet; return RR_CONTINUE_PROCESSING;}
00101 
00103     virtual void OnRakPeerStartup(void) {}
00104 
00106     virtual void OnRakPeerShutdown(void) {}
00107 
00112     virtual void OnClosedConnection(const SystemAddress &systemAddress, RakNetGUID rakNetGUID, PI2_LostConnectionReason lostConnectionReason ){(void) systemAddress; (void) rakNetGUID; (void) lostConnectionReason;}
00113 
00118     virtual void OnNewConnection(const SystemAddress &systemAddress, RakNetGUID rakNetGUID, bool isIncoming) {(void) systemAddress; (void) rakNetGUID; (void) isIncoming;}
00119 
00123     virtual void OnFailedConnectionAttempt(Packet *packet, PI2_FailedConnectionAttemptReason failedConnectionAttemptReason) {(void) packet; (void) failedConnectionAttemptReason;}
00124 
00129     virtual void OnDirectSocketSend(const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress) {(void) data; (void) bitsUsed; (void) remoteSystemAddress;}
00130     
00135     virtual void OnDirectSocketReceive(const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress) {(void) data; (void) bitsUsed; (void) remoteSystemAddress;}
00136 
00140     virtual void OnReliabilityLayerPacketError(const char *errorMessage, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress)  {(void) errorMessage; (void) bitsUsed; (void) remoteSystemAddress;}
00141     
00148     virtual void OnInternalPacket(InternalPacket *internalPacket, unsigned frameNumber, SystemAddress remoteSystemAddress, RakNet::TimeMS time, int isSend) {(void) internalPacket; (void) frameNumber; (void) remoteSystemAddress; (void) time; (void) isSend;}
00149 
00154     virtual void OnAck(unsigned int messageNumber, SystemAddress remoteSystemAddress, RakNet::TimeMS time) {(void) messageNumber; (void) remoteSystemAddress; (void) time;}
00155 
00160     virtual void OnPushBackPacket(const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress) {(void) data; (void) bitsUsed; (void) remoteSystemAddress;}
00161 
00162     RakPeerInterface *GetRakPeerInterface(void) const {return rakPeerInterface;}
00163 
00165     void SetRakPeerInterface( RakPeerInterface *ptr );
00166 
00167 #if _RAKNET_SUPPORT_PacketizedTCP==1 && _RAKNET_SUPPORT_TCPInterface==1
00168 
00169     void SetPacketizedTCP( PacketizedTCP *ptr );
00170 #endif
00171 protected:
00172     // Send through either rakPeerInterface or packetizedTCP, whichever is available
00173     void SendUnified( const RakNet::BitStream * bitStream, PacketPriority priority, PacketReliability reliability, char orderingChannel, const AddressOrGUID systemIdentifier, bool broadcast );
00174     bool SendListUnified( const char **data, const int *lengths, const int numParameters, PacketPriority priority, PacketReliability reliability, char orderingChannel, const AddressOrGUID systemIdentifier, bool broadcast );
00175 
00176     Packet *AllocatePacketUnified(unsigned dataSize);
00177     void PushBackPacketUnified(Packet *packet, bool pushAtHead);
00178     void DeallocPacketUnified(Packet *packet);
00179 
00180     // Filled automatically in when attached
00181     RakPeerInterface *rakPeerInterface;
00182 #if _RAKNET_SUPPORT_PacketizedTCP==1 && _RAKNET_SUPPORT_TCPInterface==1
00183     PacketizedTCP *packetizedTCP;
00184 #endif
00185 };
00186 
00187 } // namespace RakNet
00188 
00189 #endif
00190 

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