ENetMultiplayerPeer
An ENet/UDP multiplayer transport.
Creates ENet server/client connections for MultiplayerApi. CreateClient begins connecting; API state/signals determine completion. The server peer has ID 1; client IDs are temporary and do not replace accounts.
Choose transfer mode/channels for the data. Reliable is not durable result confirmation after disconnection. ENet does not automatically add authentication, encryption, NAT traversal or server gameplay rules.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
ENetMultiplayerPeerConstructor
public ENetMultiplayerPeer();Properties1
HostProperty
public ENetConnection Host { get; }The underlying ENetConnection created after ENetMultiplayerPeer.CreateClient and ENetMultiplayerPeer.CreateServer.
Methods7
AddMeshPeerError
public Error AddMeshPeer(int peerId, ENetConnection host);Add a new remote peer with the given peer_id connected to the given ENetMultiplayerPeer.Host.
Note: The ENetMultiplayerPeer.Host must have exactly one peer in the ENetPacketPeer.PeerState.Connected state.
| Name | Type | Default |
|---|---|---|
peerId | int | — |
host | ENetConnection | — |
ErrorCreateClientError
public Error CreateClient(string address, int port, int channelCount = 0, int inBandwidth = 0, int outBandwidth = 0, int localPort = 0);Begins an ENet connection. Error.Ok does not mean ConnectedToServer. Coordinate user-channel counts and handle failure/disconnection.
| Name | Type | Default |
|---|---|---|
address | string | — |
port | int | — |
channelCount | int | 0 |
inBandwidth | int | 0 |
outBandwidth | int | 0 |
localPort | int | 0 |
ErrorCreateMeshError
public Error CreateMesh(int uniqueId);Initialize this MultiplayerPeer in mesh mode. The provided unique_id will be used as the local peer network unique ID once assigned as the MultiplayerApi.MultiplayerPeer. In the mesh configuration you will need to set up each new peer manually using ENetConnection before calling ENetMultiplayerPeer.AddMeshPeer. While this technique is more advanced, it allows for better control over the connection process (e.g. when dealing with NAT punch-through) and for better distribution of the network load (which would otherwise be more taxing on the server).
| Name | Type | Default |
|---|---|---|
uniqueId | int | — |
ErrorCreateServerError
public Error CreateServer(int port, int maxClients = 32, int maxChannels = 0, int inBandwidth = 0, int outBandwidth = 0);Creates an ENet server on a UDP port. Configure bind IP first. Port 0 lets the OS choose a free port; a client limit is not authentication.
| Name | Type | Default |
|---|---|---|
port | int | — |
maxClients | int | 32 |
maxChannels | int | 0 |
inBandwidth | int | 0 |
outBandwidth | int | 0 |
ErrorGetHostENetConnection
public ENetConnection GetHost();ENetConnectionGetPeerENetPacketPeer
public ENetPacketPeer GetPeer(int id);Returns the ENetPacketPeer associated to the given id.
| Name | Type | Default |
|---|---|---|
id | int | — |
ENetPacketPeerSetBindIPvoid
public void SetBindIP(string iP);Sets the local bind address before creating a connection. 127.0.0.1 is reachable only on the same machine; deployment requires separate interface/routing choices.
| Name | Type | Default |
|---|---|---|
iP | string | — |