SLikeNet 0.1.3

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

- File List
- File Members

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
44 enum PluginReceiveResult
45 {
47 RR_STOP_PROCESSING_AND_DEALLOCATE=0,
48
50 RR_CONTINUE_PROCESSING,
51
53 RR_STOP_PROCESSING
54 };
55
58 enum PI2_LostConnectionReason
59 {
61 LCR_CLOSED_BY_USER,
62
64 LCR_DISCONNECTION_NOTIFICATION,
65
67 LCR_CONNECTION_LOST
68 };
69
72 enum PI2_FailedConnectionAttemptReason
73 {
74 FCAR_CONNECTION_ATTEMPT_FAILED,
75 FCAR_ALREADY_CONNECTED,
76 FCAR_NO_FREE_INCOMING_CONNECTIONS,
77 FCAR_SECURITY_PUBLIC_KEY_MISMATCH,
78 FCAR_CONNECTION_BANNED,
79 FCAR_INVALID_PASSWORD,
80 FCAR_INCOMPATIBLE_PROTOCOL,
81 FCAR_IP_RECENTLY_CONNECTED,
82 FCAR_REMOTE_SYSTEM_REQUIRES_PUBLIC_KEY,
83 FCAR_OUR_SYSTEM_REQUIRES_SECURITY,
84 FCAR_PUBLIC_KEY_MISMATCH
85 };
86
94 class RAK_DLL_EXPORT PluginInterface2
95 {
96 public:
97 PluginInterface2();
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
207 RakPeerInterface *rakPeerInterface;
208 #if _RAKNET_SUPPORT_TCPInterface==1
209 TCPInterface *tcpInterface;
210 #endif
211 };
212
213 } // namespace SLNet
214
215 #endif
216