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
peerinterface.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
22 #ifndef __RAK_PEER_INTERFACE_H
23 #define __RAK_PEER_INTERFACE_H
24
25 #include "PacketPriority.h"
26 #include "types.h"
27 #include "memoryoverride.h"
28 #include "Export.h"
29 #include "DS_List.h"
30 #include "smartptr.h"
31 #include "socket2.h"
32
33 namespace SLNet
34 {
35 // Forward declarations
36 class BitStream;
37 class PluginInterface2;
38 struct RPCMap;
39 struct RakNetStatistics;
40 struct RakNetBandwidth;
41 class RouterInterface;
42 class NetworkIDManager;
43
47 class RAK_DLL_EXPORT RakPeerInterface
48 {
49 public:
50 // GetInstance() and DestroyInstance(instance*)
51 STATIC_FACTORY_DECLARATIONS(RakPeerInterface)
52
53
54 virtual ~RakPeerInterface() {}
55
56 // --------------------------------------------------------------------------------------------Major Low Level Functions - Functions needed by most users--------------------------------------------------------------------------------------------
69 virtual StartupResult Startup( unsigned int maxConnections, SocketDescriptor *socketDescriptors, unsigned socketDescriptorCount, int threadPriority=-99999 )=0;
70
80 virtual bool InitializeSecurity( const char *publicKey, const char *privateKey, bool bRequireClientKey = false )=0;
81
84 virtual void DisableSecurity( void )=0;
85
90 virtual void AddToSecurityExceptionList(const char *ip)=0;
91
94 virtual void RemoveFromSecurityExceptionList(const char *ip)=0;
95
98 virtual bool IsInSecurityExceptionList(const char *ip)=0;
99
105 virtual void SetMaximumIncomingConnections( unsigned short numberAllowed )=0;
106
109 virtual unsigned int GetMaximumIncomingConnections( void ) const=0;
110
113 virtual unsigned short NumberOfConnections(void) const=0;
114
119 virtual void SetIncomingPassword( const char* passwordData, int passwordDataLength )=0;
120
124 virtual void GetIncomingPassword( char* passwordData, int *passwordDataLength )=0;
125
144 virtual ConnectionAttemptResult Connect( const char* host, unsigned short remotePort, const char *passwordData, int passwordDataLength, PublicKey *publicKey=0, unsigned connectionSocketIndex=0, unsigned sendConnectionAttemptCount=12, unsigned timeBetweenSendConnectionAttemptsMS=500, SLNet::TimeMS timeoutTime=0 )=0;
145
157 virtual ConnectionAttemptResult ConnectWithSocket(const char* host, unsigned short remotePort, const char *passwordData, int passwordDataLength, RakNetSocket2* socket, PublicKey *publicKey=0, unsigned sendConnectionAttemptCount=12, unsigned timeBetweenSendConnectionAttemptsMS=500, SLNet::TimeMS timeoutTime=0)=0;
158
163 //virtual bool Console2LobbyConnect( void *networkServiceId, const char *passwordData, int passwordDataLength )=0;
164
170 virtual void Shutdown( unsigned int blockDuration, unsigned char orderingChannel=0, PacketPriority disconnectionNotificationPriority=LOW_PRIORITY )=0;
171
174 virtual bool IsActive( void ) const=0;
175
179 virtual bool GetConnectionList( SystemAddress *remoteSystems, unsigned short *numberOfSystems ) const=0;
180
184 virtual uint32_t GetNextSendReceipt(void)=0;
185
189 virtual uint32_t IncrementNextSendReceipt(void)=0;
190
203 virtual uint32_t Send( const char *data, const int length, PacketPriority priority, PacketReliability reliability, char orderingChannel, const AddressOrGUID systemIdentifier, bool broadcast, uint32_t forceReceiptNumber=0 )=0;
204
210 virtual void SendLoopback( const char *data, const int length )=0;
211
222 virtual uint32_t Send( const SLNet::BitStream * bitStream, PacketPriority priority, PacketReliability reliability, char orderingChannel, const AddressOrGUID systemIdentifier, bool broadcast, uint32_t forceReceiptNumber=0 )=0;
223
244 virtual uint32_t SendList( const char **data, const int *lengths, const int numParameters, PacketPriority priority, PacketReliability reliability, char orderingChannel, const AddressOrGUID systemIdentifier, bool broadcast, uint32_t forceReceiptNumber=0 )=0;
245
252 virtual Packet* Receive( void )=0;
253
256 virtual void DeallocatePacket( Packet *packet )=0;
257
259 virtual unsigned int GetMaximumNumberOfPeers( void ) const=0;
260
261 // -------------------------------------------------------------------------------------------- Connection Management Functions--------------------------------------------------------------------------------------------
267 virtual void CloseConnection( const AddressOrGUID target, bool sendDisconnectionNotification, unsigned char orderingChannel=0, PacketPriority disconnectionNotificationPriority=LOW_PRIORITY )=0;
268
273 virtual ConnectionState GetConnectionState(const AddressOrGUID systemIdentifier)=0;
274
278 virtual void CancelConnectionAttempt( const SystemAddress target )=0;
279
283 virtual int GetIndexFromSystemAddress( const SystemAddress systemAddress ) const=0;
284
289 virtual SystemAddress GetSystemAddressFromIndex( unsigned int index )=0;
290
294 virtual RakNetGUID GetGUIDFromIndex( unsigned int index )=0;
295
300 virtual void GetSystemList(DataStructures::List<SystemAddress> &addresses, DataStructures::List<RakNetGUID> &guids) const=0;
301
305 virtual void AddToBanList( const char *IP, SLNet::TimeMS milliseconds=0 )=0;
306
309 virtual void RemoveFromBanList( const char *IP )=0;
310
312 virtual void ClearBanList( void )=0;
313
317 virtual bool IsBanned( const char *IP )=0;
318
322 virtual void SetLimitIPConnectionFrequency(bool b)=0;
323
324 // --------------------------------------------------------------------------------------------Pinging Functions - Functions dealing with the automatic ping mechanism--------------------------------------------------------------------------------------------
328 virtual void Ping( const SystemAddress target )=0;
329
337 virtual bool Ping( const char* host, unsigned short remotePort, bool onlyReplyOnAcceptingConnections, unsigned connectionSocketIndex=0 )=0;
338
342 virtual int GetAveragePing( const AddressOrGUID systemIdentifier )=0;
343
347 virtual int GetLastPing( const AddressOrGUID systemIdentifier ) const=0;
348
352 virtual int GetLowestPing( const AddressOrGUID systemIdentifier ) const=0;
353
358 virtual void SetOccasionalPing( bool doPing )=0;
359
364 virtual SLNet::Time GetClockDifferential( const AddressOrGUID systemIdentifier )=0;
365
366 // --------------------------------------------------------------------------------------------Static Data Functions - Functions dealing with API defined synchronized memory--------------------------------------------------------------------------------------------
372 virtual void SetOfflinePingResponse( const char *data, const unsigned int length )=0;
373
378 virtual void GetOfflinePingResponse( char **data, unsigned int *length )=0;
379
380 //--------------------------------------------------------------------------------------------Network Functions - Functions dealing with the network in general--------------------------------------------------------------------------------------------
386 virtual SystemAddress GetInternalID( const SystemAddress systemAddress=UNASSIGNED_SYSTEM_ADDRESS, const int index=0 ) const=0;
387
391 virtual void SetInternalID(SystemAddress systemAddress, int index=0)=0;
392
396 virtual SystemAddress GetExternalID( const SystemAddress target ) const=0;
397
399 virtual const RakNetGUID GetMyGUID(void) const=0;
400
402 virtual SystemAddress GetMyBoundAddress(const int socketIndex=0)=0;
403
405 static uint64_t Get64BitUniqueRandomNumber(void);
406
414 virtual const RakNetGUID& GetGuidFromSystemAddress( const SystemAddress input ) const=0;
415
421 virtual SystemAddress GetSystemAddressFromGuid( const RakNetGUID input ) const=0;
422
427 virtual bool GetClientPublicKeyFromSystemAddress( const SystemAddress input, char *client_public_key ) const=0;
428
434 virtual void SetTimeoutTime(SLNet::TimeMS timeMS, const SystemAddress target )=0;
435
438 virtual SLNet::TimeMS GetTimeoutTime( const SystemAddress target )=0;
439
443 virtual int GetMTUSize( const SystemAddress target ) const=0;
444
446 virtual unsigned GetNumberOfAddresses( void )=0;
447
451 virtual const char* GetLocalIP( unsigned int index )=0;
452
456 virtual bool IsLocalIP( const char *ip )=0;
457
461 virtual void AllowConnectionResponseIPMigration( bool allow )=0;
462
472 virtual bool AdvertiseSystem( const char *host, unsigned short remotePort, const char *data, int dataLength, unsigned connectionSocketIndex=0 )=0;
473
479 virtual void SetSplitMessageProgressInterval(int interval)=0;
480
483 virtual int GetSplitMessageProgressInterval(void) const=0;
484
489 virtual void SetUnreliableTimeout(SLNet::TimeMS timeoutMS)=0;
490
494 virtual void SendTTL( const char* host, unsigned short remotePort, int ttl, unsigned connectionSocketIndex=0 )=0;
495
496 // -------------------------------------------------------------------------------------------- Plugin Functions--------------------------------------------------------------------------------------------
500 virtual void AttachPlugin( PluginInterface2 *plugin )=0;
501
506 virtual void DetachPlugin( PluginInterface2 *messageHandler )=0;
507
508 // --------------------------------------------------------------------------------------------Miscellaneous Functions--------------------------------------------------------------------------------------------
512 virtual void PushBackPacket( Packet *packet, bool pushAtHead )=0;
513
518 virtual void ChangeSystemAddress(RakNetGUID guid, const SystemAddress &systemAddress)=0;
519
524 virtual Packet* AllocatePacket(unsigned dataSize)=0;
525
531 virtual RakNetSocket2* GetSocket( const SystemAddress target )=0;
532
536 virtual void GetSockets( DataStructures::List<RakNetSocket2* > &sockets )=0;
537 virtual void ReleaseSockets( DataStructures::List<RakNetSocket2* > &sockets )=0;
538
539 virtual void WriteOutOfBandHeader(SLNet::BitStream *bitStream)=0;
540
544 virtual void SetUserUpdateThread(void (*_userUpdateThreadPtr)(RakPeerInterface *, void *), void *_userUpdateThreadData)=0;
545
553 virtual void SetIncomingDatagramEventHandler( bool (*_incomingDatagramEventHandler)(RNS2RecvStruct *) )=0;
554
555 // --------------------------------------------------------------------------------------------Network Simulator Functions--------------------------------------------------------------------------------------------
564 virtual void ApplyNetworkSimulator( float packetloss, unsigned short minExtraPing, unsigned short extraPingVariance)=0;
565
570 virtual void SetPerConnectionOutgoingBandwidthLimit( unsigned maxBitsPerSecond )=0;
571
574 virtual bool IsNetworkSimulatorActive( void )=0;
575
576 // --------------------------------------------------------------------------------------------Statistical Functions - Functions dealing with API performance--------------------------------------------------------------------------------------------
577
584 virtual RakNetStatistics * GetStatistics( const SystemAddress systemAddress, RakNetStatistics *rns=0 )=0;
587 virtual bool GetStatistics( const unsigned int index, RakNetStatistics *rns )=0;
593 virtual void GetStatisticsList(DataStructures::List<SystemAddress> &addresses, DataStructures::List<RakNetGUID> &guids, DataStructures::List<RakNetStatistics> &statistics)=0;
594
596 virtual unsigned int GetReceiveBufferSize(void)=0;
597
598 // --------------------------------------------------------------------------------------------EVERYTHING AFTER THIS COMMENT IS FOR INTERNAL USE ONLY--------------------------------------------------------------------------------------------
599
601 // Call manually if RAKPEER_USER_THREADED==1 at least every 30 milliseconds.
602 // updateBitStream should be:
603 // BitStream updateBitStream( MAXIMUM_MTU_SIZE
604 // #if LIBCAT_SECURITY==1
605 // + cat::AuthenticatedEncryption::OVERHEAD_BYTES
606 // #endif
607 // );
608 virtual bool RunUpdateCycle( BitStream &updateBitStream )=0;
609
611 virtual bool SendOutOfBand(const char *host, unsigned short remotePort, const char *data, BitSize_t dataLength, unsigned connectionSocketIndex=0 )=0;
612
613 }
614 // #if defined(SN_TARGET_PSP2)
615 // __attribute__((aligned(8)))
616 // #endif
617 ;
618
619 } // namespace SLNet
620
621 #endif