|
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. More...
|
|
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 same channel number. More...
|
|
virtual bool | IsP2PPacketAvailable (uint32_t *outMsgSize, uint8_t channel=0)=0 |
| Checks for any incoming packets on a specified channel. More...
|
|
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 same channel number. More...
|
|
virtual void | PopP2PPacket (uint8_t channel=0)=0 |
| Removes the first packet from the packet queue. More...
|
|
virtual int | GetPingWith (GalaxyID galaxyID)=0 |
| Retrieves current ping value in milliseconds with a specified entity, i.e. More...
|
|
virtual void | RequestNatTypeDetection ()=0 |
| Initiates a NAT type detection process. More...
|
|
virtual NatType | GetNatType ()=0 |
| Retrieves determined NAT type. More...
|
|
virtual ConnectionType | GetConnectionType (GalaxyID userID)=0 |
| Retrieves connection type of the specified user. More...
|
|
The interface for communicating with other Galaxy Peers.
virtual bool PeekP2PPacket |
( |
void * |
dest, |
|
|
uint32_t |
destSize, |
|
|
uint32_t * |
outMsgSize, |
|
|
GalaxyID & |
outGalaxyID, |
|
|
uint8_t |
channel = 0 |
|
) |
| |
|
pure virtual |
Reads an incoming packet that was sent from another Galaxy Peer by calling SendP2PPacket() with the same channel number.
The packet that was read this way is left in the packet queue.
If the buffer that is supposed to take the data is too small, the message will be truncated to its size. The size of the packet is provided in the notification about an incoming packet in INetworkingListener during which this call is intended to be performed.
This call is non-blocking and operates on the awaiting packets that have already come to the Galaxy Peer, thus instantly finishes, claiming a failure if there are no packets on the specified channel yet.
- Parameters
-
[in,out] | dest | The buffer to pass the data to. |
[in] | destSize | The size of the buffer. |
[in,out] | outMsgSize | The size of the message. |
[out] | outGalaxyID | The ID of the user who sent the packet. |
[in] | channel | The number of the channel to use. |
- Returns
- true if succeeded, false when there are no packets.
virtual bool ReadP2PPacket |
( |
void * |
dest, |
|
|
uint32_t |
destSize, |
|
|
uint32_t * |
outMsgSize, |
|
|
GalaxyID & |
outGalaxyID, |
|
|
uint8_t |
channel = 0 |
|
) |
| |
|
pure virtual |
Reads an incoming packet that was sent from another Galaxy Peer by calling SendP2PPacket() with the same channel number.
The packet that was read this way is removed from the packet queue.
This call is non-blocking and operates on the awaiting packets that have already come to the Galaxy Peer, thus instantly finishes, claiming a failure if there are no packets on the specified channel yet.
- Precondition
- If the buffer that is supposed to take the data is too small, the message will be truncated to its size. For that reason prior to reading a packet it is recommended to check for it by calling IsP2PPacketAvailable(), which also returns the packet size.
- Parameters
-
[in,out] | dest | The buffer to pass the data to. |
[in] | destSize | The size of the buffer. |
[in,out] | outMsgSize | The size of the message. |
[out] | outGalaxyID | The ID of the user who sent the packet. |
[in] | channel | The number of the channel to use. |
- Returns
- true if succeeded, false when there are no packets.
virtual bool SendP2PPacket |
( |
GalaxyID |
galaxyID, |
|
|
const void * |
data, |
|
|
uint32_t |
dataSize, |
|
|
P2PSendType |
sendType, |
|
|
uint8_t |
channel = 0 |
|
) |
| |
|
pure virtual |
Sends a P2P packet to a specified user.
It is possible to communicate only with the users within the same lobby. It is recommended to send 1200 bytes at most in a single packet.
The channel is a routing number that allows to implement separate layers of communication while using the same existing connection in order to save some network resources. Since there is only a single connection between each two Galaxy Peers, the Galaxy Peer that is supposed to receive the packet needs to know which channel number to use when checking for incoming packets.
In order to receive the packet on the other Galaxy Peer, call there ReadP2PPacket() with the same channel number.
Packets addressed to a user (by providing a user ID as the GalaxyID) need to be received with the networking interface. Packets addressed to a lobby (by providing a lobby ID as the GalaxyID) come to the lobby owner that also acts as the game server.
- Parameters
-
[in] | galaxyID | ID of the specified user to whom the packet is to be sent. |
[in] | data | The data to send. |
[in] | dataSize | The size of the data. |
[in] | sendType | The level of reliability of the operation. |
[in] | channel | The number of the channel to use. |
- Returns
- true if the packet was scheduled for sending, false otherwise.