GOG GALAXY SDK Documentation
ICustomNetworking.h
Go to the documentation of this file.
1 #ifndef GALAXY_I_CUSTOM_NETWORKING_H
2 #define GALAXY_I_CUSTOM_NETWORKING_H
3 
10 #include "IListenerRegistrar.h"
11 
12 namespace galaxy
13 {
14  namespace api
15  {
24  typedef uint64_t ConnectionID;
25 
29  class IConnectionOpenListener : public GalaxyTypeAwareListener<CUSTOM_NETWORKING_CONNECTION_OPEN>
30  {
31  public:
32 
39  virtual void OnConnectionOpenSuccess(const char* connectionString, ConnectionID connectionID) = 0;
40 
45  {
49  };
50 
57  virtual void OnConnectionOpenFailure(const char* connectionString, FailureReason failureReason) = 0;
58  };
59 
64 
69  class IConnectionCloseListener : public GalaxyTypeAwareListener<CUSTOM_NETWORKING_CONNECTION_CLOSE>
70  {
71  public:
72 
77  {
79  };
80 
87  virtual void OnConnectionClosed(ConnectionID connectionID, CloseReason closeReason) = 0;
88  };
89 
94 
98  class IConnectionDataListener : public GalaxyTypeAwareListener<CUSTOM_NETWORKING_CONNECTION_DATA>
99  {
100  public:
101 
108  virtual void OnConnectionDataReceived(ConnectionID connectionID, uint32_t dataSize) = 0;
109  };
110 
115 
120  {
121  public:
122 
123  virtual ~ICustomNetworking()
124  {
125  }
126 
137  virtual void OpenConnection(const char* connectionString, IConnectionOpenListener* const listener = NULL) = 0;
138 
147  virtual void CloseConnection(ConnectionID connectionID, IConnectionCloseListener* const listener = NULL) = 0;
148 
156  virtual void SendData(ConnectionID connectionID, const void* data, uint32_t dataSize) = 0;
157 
164  virtual uint32_t GetAvailableDataSize(ConnectionID connectionID) = 0;
165 
174  virtual void PeekData(ConnectionID connectionID, void* dest, uint32_t dataSize) = 0;
175 
184  virtual void ReadData(ConnectionID connectionID, void* dest, uint32_t dataSize) = 0;
185 
192  virtual void PopData(ConnectionID connectionID, uint32_t dataSize) = 0;
193  };
194 
196  }
197 }
198 
199 #endif
Contains data structures and interfaces related to callback listeners.
The class that is inherited by all specific callback listeners and provides a static method that retu...
Definition: IListenerRegistrar.h:117
Listener for the event of closing a connection.
Definition: ICustomNetworking.h:70
CloseReason
The reason of closing a connection.
Definition: ICustomNetworking.h:77
@ CLOSE_REASON_UNDEFINED
Unspecified reason.
Definition: ICustomNetworking.h:78
virtual void OnConnectionClosed(ConnectionID connectionID, CloseReason closeReason)=0
Notification for the event of closing a connection.
Listener for the event of receiving data over the connection.
Definition: ICustomNetworking.h:99
virtual void OnConnectionDataReceived(ConnectionID connectionID, uint32_t dataSize)=0
Notification for the event of receiving data over the connection.
Listener for the events related to opening a connection.
Definition: ICustomNetworking.h:30
FailureReason
The reason of a failure in opening a connection.
Definition: ICustomNetworking.h:45
@ FAILURE_REASON_UNAUTHORIZED
Client is unauthorized.
Definition: ICustomNetworking.h:48
@ FAILURE_REASON_UNDEFINED
Unspecified error.
Definition: ICustomNetworking.h:46
@ FAILURE_REASON_CONNECTION_FAILURE
Unable to communicate with backend services.
Definition: ICustomNetworking.h:47
virtual void OnConnectionOpenFailure(const char *connectionString, FailureReason failureReason)=0
Notification for the event of a failure in opening a connection.
virtual void OnConnectionOpenSuccess(const char *connectionString, ConnectionID connectionID)=0
Notification for the event of a success in opening a connection.
The interface for communicating with a custom endpoint.
Definition: ICustomNetworking.h:120
virtual uint32_t GetAvailableDataSize(ConnectionID connectionID)=0
Returns the number of bytes in a specific connection incoming buffer.
virtual void PopData(ConnectionID connectionID, uint32_t dataSize)=0
Removes a given number of bytes from a specific connection incoming buffer.
virtual void ReadData(ConnectionID connectionID, void *dest, uint32_t dataSize)=0
Reads binary data received from a specific connection.
virtual void CloseConnection(ConnectionID connectionID, IConnectionCloseListener *const listener=NULL)=0
Close a connection.
virtual void PeekData(ConnectionID connectionID, void *dest, uint32_t dataSize)=0
Reads binary data received from a specific connection.
virtual void OpenConnection(const char *connectionString, IConnectionOpenListener *const listener=NULL)=0
Open a connection with a specific endpoint.
virtual void SendData(ConnectionID connectionID, const void *data, uint32_t dataSize)=0
Send binary data over a specific connection.
The class that is inherited by the self-registering versions of all specific callback listeners.
Definition: IListenerRegistrar.h:211
SelfRegisteringListener< IConnectionCloseListener > GlobalConnectionCloseListener
Globally self-registering version of IConnectionCloseListener.
Definition: ICustomNetworking.h:93
uint64_t ConnectionID
ID of a connection.
Definition: ICustomNetworking.h:24
SelfRegisteringListener< IConnectionOpenListener > GlobalConnectionOpenListener
Globally self-registering version of IConnectionOpenListener.
Definition: ICustomNetworking.h:63
SelfRegisteringListener< IConnectionDataListener > GlobalConnectionDataListener
Globally self-registering version of IConnectionDataListener.
Definition: ICustomNetworking.h:114