GOG GALAXY SDK Documentation
INetworking.h
Go to the documentation of this file.
1 #ifndef GALAXY_I_NETWORKING_H
2 #define GALAXY_I_NETWORKING_H
3 
10 #include "IListenerRegistrar.h"
11 #include "GalaxyID.h"
12 
13 namespace galaxy
14 {
15  namespace api
16  {
25  class INetworkingListener : public GalaxyTypeAwareListener<NETWORKING>
26  {
27  public:
28 
35  virtual void OnP2PPacketAvailable(uint32_t msgSize, uint8_t channel) = 0;
36  };
37 
42 
47 
51  enum NatType
52  {
59  };
60 
64  class INatTypeDetectionListener : public GalaxyTypeAwareListener<NAT_TYPE_DETECTION>
65  {
66  public:
67 
73  virtual void OnNatTypeDetectionSuccess(NatType natType) = 0;
74 
78  virtual void OnNatTypeDetectionFailure() = 0;
79  };
80 
85 
90 
97  {
102  };
103 
108  {
112  };
113 
118  {
119  public:
120 
121  virtual ~INetworking()
122  {
123  }
124 
153  virtual bool SendP2PPacket(GalaxyID galaxyID, const void* data, uint32_t dataSize, P2PSendType sendType, uint8_t channel = 0) = 0;
154 
179  virtual bool PeekP2PPacket(void* dest, uint32_t destSize, uint32_t* outMsgSize, GalaxyID& outGalaxyID, uint8_t channel = 0) = 0;
180 
192  virtual bool IsP2PPacketAvailable(uint32_t* outMsgSize, uint8_t channel = 0) = 0;
193 
223  virtual bool ReadP2PPacket(void* dest, uint32_t destSize, uint32_t* outMsgSize, GalaxyID& outGalaxyID, uint8_t channel = 0) = 0;
224 
235  virtual void PopP2PPacket(uint8_t channel = 0) = 0;
236 
250  virtual int GetPingWith(GalaxyID galaxyID) = 0;
251 
260  virtual void RequestNatTypeDetection() = 0;
261 
275  virtual NatType GetNatType() = 0;
276 
286 
287  };
288 
290  }
291 }
292 
293 #endif
Contains GalaxyID, which is the class that represents the ID of an entity used by Galaxy Peer.
Contains data structures and interfaces related to callback listeners.
Represents the ID of an entity used by Galaxy Peer.
Definition: GalaxyID.h:30
The class that is inherited by all specific callback listeners and provides a static method that retu...
Definition: IListenerRegistrar.h:117
Listener for the events related to NAT type detection.
Definition: INetworking.h:65
virtual void OnNatTypeDetectionSuccess(NatType natType)=0
Notification for the event of a success in NAT type detection.
virtual void OnNatTypeDetectionFailure()=0
Notification for the event of a failure in NAT type detection.
Listener for the events related to packets that come to the client.
Definition: INetworking.h:26
virtual void OnP2PPacketAvailable(uint32_t msgSize, uint8_t channel)=0
Notification for the event of receiving a packet.
The interface for communicating with other Galaxy Peers.
Definition: INetworking.h:118
virtual bool ReadP2PPacket(void *dest, uint32_t destSize, uint32_t *outMsgSize, GalaxyID &outGalaxyID, uint8_t channel=0)=0
Reads an incoming packet that was sent from another Galaxy Peer by calling SendP2PPacket() with the s...
virtual bool SendP2PPacket(GalaxyID galaxyID, const void *data, uint32_t dataSize, P2PSendType sendType, uint8_t channel=0)=0
Sends a P2P packet to a specified user.
virtual void RequestNatTypeDetection()=0
Initiates a NAT type detection process.
virtual int GetPingWith(GalaxyID galaxyID)=0
Retrieves current ping value in milliseconds with a specified entity, i.e.
virtual void PopP2PPacket(uint8_t channel=0)=0
Removes the first packet from the packet queue.
virtual ConnectionType GetConnectionType(GalaxyID userID)=0
Retrieves connection type of the specified user.
virtual bool PeekP2PPacket(void *dest, uint32_t destSize, uint32_t *outMsgSize, GalaxyID &outGalaxyID, uint8_t channel=0)=0
Reads an incoming packet that was sent from another Galaxy Peer by calling SendP2PPacket() with the s...
virtual bool IsP2PPacketAvailable(uint32_t *outMsgSize, uint8_t channel=0)=0
Checks for any incoming packets on a specified channel.
virtual NatType GetNatType()=0
Retrieves determined NAT type.
The class that is inherited by the self-registering versions of all specific callback listeners.
Definition: IListenerRegistrar.h:211
SelfRegisteringListener< INatTypeDetectionListener, GameServerListenerRegistrar > GameServerGlobalNatTypeDetectionListener
Globally self-registering version of INatTypeDetectionListener for the GameServer.
Definition: INetworking.h:89
SelfRegisteringListener< INetworkingListener, GameServerListenerRegistrar > GameServerGlobalNetworkingListener
Globally self-registering version of INetworkingListener for the GameServer.
Definition: INetworking.h:46
SelfRegisteringListener< INatTypeDetectionListener > GlobalNatTypeDetectionListener
Globally self-registering version of INatTypeDetectionListener.
Definition: INetworking.h:84
SelfRegisteringListener< INetworkingListener > GlobalNetworkingListener
Globally self-registering version of INetworkingListener.
Definition: INetworking.h:41
NatType
NAT types.
Definition: INetworking.h:52
ConnectionType
Connection types.
Definition: INetworking.h:108
P2PSendType
Send type used when calling INetworking::SendP2PPacket() in order to specify desired reliability of t...
Definition: INetworking.h:97
@ NAT_TYPE_PORT_RESTRICTED
Accepts datagrams to a port if the datagram source IP address and port belongs a system that has been...
Definition: INetworking.h:56
@ NAT_TYPE_SYMMETRIC
A different port is chosen for every remote destination.
Definition: INetworking.h:57
@ NAT_TYPE_ADDRESS_RESTRICTED
Accepts datagrams to a port if the datagram source IP address belongs to a system that has been sent ...
Definition: INetworking.h:55
@ NAT_TYPE_NONE
There is no NAT at all.
Definition: INetworking.h:53
@ NAT_TYPE_FULL_CONE
Accepts any datagrams to a port that has been previously used.
Definition: INetworking.h:54
@ NAT_TYPE_UNKNOWN
NAT type has not been determined.
Definition: INetworking.h:58
@ CONNECTION_TYPE_DIRECT
User is connected directly.
Definition: INetworking.h:110
@ CONNECTION_TYPE_NONE
User is connected only with server.
Definition: INetworking.h:109
@ CONNECTION_TYPE_PROXY
User is connected through a proxy.
Definition: INetworking.h:111
@ P2P_SEND_UNRELIABLE_IMMEDIATE
UDP-like packet transfer. The packet will be sent instantly.
Definition: INetworking.h:100
@ P2P_SEND_RELIABLE
TCP-like packet transfer. The packet will be sent during the next call to ProcessData().
Definition: INetworking.h:99
@ P2P_SEND_RELIABLE_IMMEDIATE
TCP-like packet transfer. The packet will be sent instantly.
Definition: INetworking.h:101
@ P2P_SEND_UNRELIABLE
UDP-like packet transfer. The packet will be sent during the next call to ProcessData().
Definition: INetworking.h:98