FGnsTransport
INetworkTransport over Valve's GameNetworkingSockets, linked standalone (no Steam client): client/server over IP for dedicated and listen servers. The library brings what ENet leaves to the engine — per-connection encryption (ephemeral key exchange, AES-GCM), pacing, message fragmentation up to 512 KB, and lanes — and the four engine channels map onto four lanes of one connection.
- Module
- Networking
- Header
#include "Networking/GnsTransport.h"- Namespace
Mowo
Identity: without a certificate authority GNS connections are encrypted but anonymous, and each end is just its IP address. Who may join is still decided by the engine: every connection runs the same join-key exchange as an encrypted ENet link (FNetCryptoSession, net.psk or the host's join key off this machine) before either side announces the peer, and when that key is not empty payloads are additionally sealed under the keys it derived, so a party that terminates GNS's anonymous handshake on both sides still cannot read or forge them. Peer ids are the transport's own counter, as with ENet; players, rejoin tokens and platform tickets live in the session layer above.
Not covered: ICE / NAT-punched P2P (it needs a signalling service the engine does not run) and Steam's relay — Steam builds use the platform transport.
IsAvailable() is false on a platform whose library was not built; Host and Connect then fail with a log line saying so.
Constructors
| Signature | Name | Description |
|---|---|---|
FGnsTransport() | FGnsTransport | |
~FGnsTransport() override | ~FGnsTransport | |
FGnsTransport(const FGnsTransport&) = delete | FGnsTransport |
Public functions
| Returns | Name | Description |
|---|---|---|
FGnsTransport& | operator= | |
bool | IsAvailable | |
bool | Host | |
uint16_t | GetBoundPort | |
bool | Connect | |
void | Disconnect | |
void | DisconnectPeer | |
void | DisconnectPeerAfterFlush | |
void | Poll | |
void | Send | |
void | Broadcast | |
ConnectionState | GetState | |
uint32_t | GetLocalPeerId | |
const std::vector<NetworkPeer>& | GetPeers | |
bool | GetPeerStats | |
std::string | GetJoinKey | |
void | SetJoinKey | |
void | SetPreSharedKey | Overrides net.psk / net.encrypt for this instance; before Host/Connect. |
void | SetEncryptionMode | |
bool | IsPeerSealed | True once the join-key exchange with this peer passed and its payloads are sealed under the derived keys (a non-empty key on both ends). |
bool | IsPeerWireEncrypted | What GNS reports about the link: encrypted on the wire (it always should be — an unencrypted connection is closed), and its end reason once closed. |
int32_t | GetLastEndReason |
Function details
FGnsTransport
FGnsTransport()~FGnsTransport
~FGnsTransport() overrideFGnsTransport
FGnsTransport(const FGnsTransport&) = deleteoperator=
FGnsTransport& operator=(const FGnsTransport&) = deleteIsAvailable
static bool IsAvailable()Host
bool Host(uint16_t port, uint32_t maxClients) overrideGetBoundPort
uint16_t GetBoundPort() const overrideConnect
bool Connect(const std::string& address, uint16_t port) overrideDisconnect
void Disconnect() overrideDisconnectPeer
void DisconnectPeer(uint32_t peerId) overrideDisconnectPeerAfterFlush
void DisconnectPeerAfterFlush(uint32_t peerId) overridePoll
void Poll(std::vector<NetworkEvent>& outEvents) overrideSend
void Send(uint32_t peerId, const void* data, size_t size, uint8_t channel) overrideBroadcast
void Broadcast(const void* data, size_t size, uint8_t channel) overrideGetState
ConnectionState GetState() const overrideGetLocalPeerId
uint32_t GetLocalPeerId() const overrideGetPeers
const std::vector<NetworkPeer>& GetPeers() const overrideGetPeerStats
bool GetPeerStats(uint32_t peerId, NetworkPeerStats& outStats) const overrideGetJoinKey
std::string GetJoinKey() const overrideSetJoinKey
void SetJoinKey(const std::string& key) overrideSetPreSharedKey
void SetPreSharedKey(const std::string& psk)Overrides net.psk / net.encrypt for this instance; before Host/Connect. Off means no join key is made up, so peers from off this machine join without one — GNS still encrypts the wire.
SetEncryptionMode
void SetEncryptionMode(ENetEncryptionMode mode)IsPeerSealed
bool IsPeerSealed(uint32_t peerId) constTrue once the join-key exchange with this peer passed and its payloads are sealed under the derived keys (a non-empty key on both ends).
IsPeerWireEncrypted
bool IsPeerWireEncrypted(uint32_t peerId) constWhat GNS reports about the link: encrypted on the wire (it always should be — an unencrypted connection is closed), and its end reason once closed. For tests and the debug panel.
GetLastEndReason
int32_t GetLastEndReason() const