SLikeNet  0.1.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PluginInterface2.h
Go to the documentation of this file.
1 /*
2  * Original work: Copyright (c) 2014, Oculus VR, Inc.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD-style license found in the
6  * RakNet License.txt file in the licenses directory of this source tree. An additional grant
7  * of patent rights can be found in the RakNet Patents.txt file in the same directory.
8  *
9  *
10  * Modified work: Copyright (c) 2017, SLikeSoft UG (haftungsbeschränkt)
11  *
12  * This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
13  * license found in the license.txt file in the root directory of this source tree.
14  */
15 
19 
20 
21 #ifndef __PLUGIN_INTERFACE_2_H
22 #define __PLUGIN_INTERFACE_2_H
23 
24 #include "NativeFeatureIncludes.h"
25 #include "types.h"
26 #include "Export.h"
27 #include "PacketPriority.h"
28 
29 namespace SLNet {
30 
32 class RakPeerInterface;
33 class TCPInterface;
34 struct Packet;
35 struct InternalPacket;
36 
38 
41 
45 {
48 
51 
54 };
55 
59 {
62 
65 
68 };
69 
73 {
85 };
86 
95 {
96 public:
98  virtual ~PluginInterface2();
99 
101  virtual void OnAttach(void) {}
102 
104  virtual void OnDetach(void) {}
105 
107  virtual void Update(void) {}
108 
112  virtual PluginReceiveResult OnReceive(Packet *packet) {(void) packet; return RR_CONTINUE_PROCESSING;}
113 
115  virtual void OnRakPeerStartup(void) {}
116 
118  virtual void OnRakPeerShutdown(void) {}
119 
124  virtual void OnClosedConnection(const SystemAddress &systemAddress, RakNetGUID rakNetGUID, PI2_LostConnectionReason lostConnectionReason ){(void) systemAddress; (void) rakNetGUID; (void) lostConnectionReason;}
125 
130  virtual void OnNewConnection(const SystemAddress &systemAddress, RakNetGUID rakNetGUID, bool isIncoming) {(void) systemAddress; (void) rakNetGUID; (void) isIncoming;}
131 
135  virtual void OnFailedConnectionAttempt(Packet *packet, PI2_FailedConnectionAttemptReason failedConnectionAttemptReason) {(void) packet; (void) failedConnectionAttemptReason;}
136 
140  virtual bool UsesReliabilityLayer(void) const {return false;}
141 
147  virtual void OnDirectSocketSend(const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress) {(void) data; (void) bitsUsed; (void) remoteSystemAddress;}
148 
154  virtual void OnDirectSocketReceive(const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress) {(void) data; (void) bitsUsed; (void) remoteSystemAddress;}
155 
160  virtual void OnReliabilityLayerNotification(const char *errorMessage, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress, bool isError) {(void) errorMessage; (void) bitsUsed; (void) remoteSystemAddress; (void) isError;}
161 
169  virtual void OnInternalPacket(InternalPacket *internalPacket, unsigned frameNumber, SystemAddress remoteSystemAddress, SLNet::TimeMS time, int isSend) {(void) internalPacket; (void) frameNumber; (void) remoteSystemAddress; (void) time; (void) isSend;}
170 
176  virtual void OnAck(unsigned int messageNumber, SystemAddress remoteSystemAddress, SLNet::TimeMS time) {(void) messageNumber; (void) remoteSystemAddress; (void) time;}
177 
182  virtual void OnPushBackPacket(const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress) {(void) data; (void) bitsUsed; (void) remoteSystemAddress;}
183 
184  RakPeerInterface *GetRakPeerInterface(void) const {return rakPeerInterface;}
185 
186  RakNetGUID GetMyGUIDUnified(void) const;
187 
189  void SetRakPeerInterface( RakPeerInterface *ptr );
190 
191 #if _RAKNET_SUPPORT_TCPInterface==1
192 
193  void SetTCPInterface( TCPInterface *ptr );
194 #endif
195 
196 protected:
197  // Send through either rakPeerInterface or tcpInterface, whichever is available
198  void SendUnified( const SLNet::BitStream * bitStream, PacketPriority priority, PacketReliability reliability, char orderingChannel, const AddressOrGUID systemIdentifier, bool broadcast );
199  void SendUnified( const char * data, const int length, PacketPriority priority, PacketReliability reliability, char orderingChannel, const AddressOrGUID systemIdentifier, bool broadcast );
200  bool SendListUnified( const char **data, const int *lengths, const int numParameters, PacketPriority priority, PacketReliability reliability, char orderingChannel, const AddressOrGUID systemIdentifier, bool broadcast );
201 
202  Packet *AllocatePacketUnified(unsigned dataSize);
203  void PushBackPacketUnified(Packet *packet, bool pushAtHead);
204  void DeallocPacketUnified(Packet *packet);
205 
206  // Filled automatically in when attached
208 #if _RAKNET_SUPPORT_TCPInterface==1
210 #endif
211 };
212 
213 } // namespace SLNet
214 
215 #endif
216