INetworkTransport
Both ENet and Steam Networking Sockets implement this.
- Module
- Networking
- Header
#include "Networking/INetworkTransport.h"- Namespace
Mowo
Constructors
| Signature | Name | Description |
|---|---|---|
virtual ~INetworkTransport() = default | ~INetworkTransport |
Public functions
| Returns | Name | Description |
|---|---|---|
bool | Host | Host a server on the given port (max clients for ENet, ignored for Steam P2P) |
uint16_t | GetBoundPort | The UDP port a host is actually listening on. |
bool | Connect | Connect to a remote host (address:port for ENet, Steam ID string for Steam) |
void | Disconnect | |
void | DisconnectPeer | Forcibly disconnect a single peer (server-side; e.g. |
void | DisconnectPeerAfterFlush | Disconnect a peer only after everything queued for it has been delivered — the cut that follows a notice (a kick reason, a join refusal). |
void | Poll | Poll for network events (non-blocking). |
void | Send | |
void | Broadcast | |
ConnectionState | GetState | |
uint32_t | GetLocalPeerId | Local peer ID (assigned by host) |
const std::vector<NetworkPeer>& | GetPeers | |
bool | GetPeerStats | |
bool | GetSimulationStats | net.sim.* counters for a debug UI. |
std::string | GetJoinKey | The secret a direct (ENet) link authenticates with. |
void | SetJoinKey |
Function details
~INetworkTransport
virtual ~INetworkTransport() = defaultHost
virtual bool Host(uint16_t port, uint32_t maxClients) = 0Host a server on the given port (max clients for ENet, ignored for Steam P2P)
GetBoundPort
virtual uint16_t GetBoundPort() constThe UDP port a host is actually listening on. Host(0, ...) asks the OS for a free one — the only choice that cannot collide with a Windows excluded port range — and this is how the caller learns which it got. 0 when not hosting or when the transport has no socket (Steam P2P).
Connect
virtual bool Connect(const std::string& address, uint16_t port) = 0Connect to a remote host (address:port for ENet, Steam ID string for Steam)
Disconnect
virtual void Disconnect() = 0DisconnectPeer
virtual void DisconnectPeer(uint32_t peerId)Forcibly disconnect a single peer (server-side; e.g. failed auth). Default no-op so transports that can't target a single peer still compile; ENet overrides it.
DisconnectPeerAfterFlush
virtual void DisconnectPeerAfterFlush(uint32_t peerId)Disconnect a peer only after everything queued for it has been delivered — the cut that follows a notice (a kick reason, a join refusal). An immediate reset on the heels of a send loses the notice: when the data and the disconnect land in one service pass the peer purges its undelivered receive queue before dispatching. Transports with no graceful form fall back to the immediate cut.
Poll
virtual void Poll(std::vector<NetworkEvent>& outEvents) = 0Poll for network events (non-blocking). Called once per frame.
Send
virtual void Send(uint32_t peerId, const void* data, size_t size, uint8_t channel) = 0Broadcast
virtual void Broadcast(const void* data, size_t size, uint8_t channel) = 0GetState
virtual ConnectionState GetState() const = 0GetLocalPeerId
virtual uint32_t GetLocalPeerId() const = 0Local peer ID (assigned by host)
GetPeers
virtual const std::vector<NetworkPeer>& GetPeers() const = 0GetPeerStats
virtual bool GetPeerStats(uint32_t peerId, NetworkPeerStats& outStats) constGetSimulationStats
virtual bool GetSimulationStats(FNetSimTransportStats& outStats) constnet.sim.* counters for a debug UI. False when this transport doesn't run its own injector — Steam pushes its FakePacketLoss/FakePacketLag knobs to the platform SDK instead of an FNetSimQueue.
GetJoinKey
virtual std::string GetJoinKey() constThe secret a direct (ENet) link authenticates with. A host reports the key it made up for the session; a client is handed the key to present before Connect. Transports that authenticate otherwise (Steam tickets) have none.
SetJoinKey
virtual void SetJoinKey(const std::string& key)