Table of Contents

Class EOSTransportManager

public class EOSTransportManager : IEOSSubManager
Inheritance
EOSTransportManager

Constructors

EOSTransportManager()

Creates a new, uninitialized instance of EOSTransportManager.

public EOSTransportManager()

EOSTransportManager(ProductUserId)

Creates a new, uninitialized instance of EOSTransportManager with an override user ID.

public EOSTransportManager(ProductUserId overrideId)

Parameters

overrideId ProductUserId

Fields

LocalUserId

The product id for the local user.

public ProductUserId LocalUserId

Field Value

ProductUserId

MaxConnections

Maximum concurrent connections with any individual remote peer.

public const int MaxConnections

Field Value

int

32

MaxPacketSize

Maximum packet byte length

public const int MaxPacketSize

Field Value

int

1170 due to DTLS/SCTP/UDP packet overhead.

NATType

Cached value of the NAT type in use.

public NATType NATType

Field Value

NATType

OnConnectionClosedCb

Callback function for closing a connection

public EOSTransportManager.OnConnectionClosedCallback OnConnectionClosedCb

Field Value

EOSTransportManager.OnConnectionClosedCallback

OnConnectionOpenedCb

Callback function for opening a connection

public EOSTransportManager.OnConnectionOpenedCallback OnConnectionOpenedCb

Field Value

EOSTransportManager.OnConnectionOpenedCallback

OnIncomingConnectionRequestedCb

Callback function for incoming connection requests.

public EOSTransportManager.OnIncomingConnectionRequestedCallback OnIncomingConnectionRequestedCb

Field Value

EOSTransportManager.OnIncomingConnectionRequestedCallback

P2PHandle

Handle to the EOS P2P interface

public P2PInterface P2PHandle

Field Value

P2PInterface

Properties

AllConnectionsCount

The total number of connections active. This includes pending connections (incoming or outgoing) and fully open connections.

public int AllConnectionsCount { get; }

Property Value

int

FullyOpenConnectionsCount

The number of fully opened connections.

public int FullyOpenConnectionsCount { get; }

Property Value

int

PendingIncomingConnectionsCount

The number of pending outgoing connections.

public int PendingIncomingConnectionsCount { get; }

Property Value

int

PendingOutgoingConnectionsCount

The number of pending outgoing connections.

public int PendingOutgoingConnectionsCount { get; }

Property Value

int

Methods

CloseAllConnections(bool)

Closes all open connections.

public bool CloseAllConnections(bool forceClose = true)

Parameters

forceClose bool

If we should ignore any connection closure related errors (which will still be logged) and continue with connection cleanup locally (calling user callbacks, etc.)

Returns

bool

true if all connections were successfully closed, false if one or more connections failed to close.

CloseAllConnectionsWithRemotePeer(ProductUserId, bool)

Closes all open connections with a given remote peer.

public bool CloseAllConnectionsWithRemotePeer(ProductUserId remoteUserId, bool forceClose = true)

Parameters

remoteUserId ProductUserId

The id of the remote user to close all connections with.

forceClose bool

If we should ignore any connection closure related errors (which will still be logged) and continue with connection cleanup locally (calling user callbacks, etc.)

Returns

bool

true if all connections with the given remote peer were successfully closed, false if one or more connections failed to close.

CloseAllConnectionsWithSocketName(string, bool)

Closes all open connections with a given socket name.

public bool CloseAllConnectionsWithSocketName(string socketName, bool forceClose = true)

Parameters

socketName string

The name of the socket to close all connections on.

forceClose bool

If we should ignore any connection closure related errors (which will still be logged) and continue with connection cleanup locally (calling user callbacks, etc.)

Returns

bool

true if all connections with the given socket name were successfully closed, false if one or more connections failed to close.

CloseConnection(ProductUserId, string, bool)

Closes (cancels/rejects) a named socket connection with a remote peer.

public bool CloseConnection(ProductUserId remoteUserId, string socketName, bool forceClose = true)

Parameters

remoteUserId ProductUserId

The id of the remote peer to close connection with.

socketName string

The name of the socket the exiting connection is on.

forceClose bool

If we should ignore any connection closure related errors (which will still be logged) and continue with connection cleanup locally (calling user callbacks, etc.)

Returns

bool

true if a matching remote peer connection was found and closed, false if not.

Disconnect(bool)

public void Disconnect(bool discardMessageQueue = false)

Parameters

discardMessageQueue bool

GetDebugString(bool)

Gets a string containing debug information related to the state of the P2P manager.

public string GetDebugString(bool includeConnections = false)

Parameters

includeConnections bool

Returns

string

A JSON formatted string containing the local user id, NAT type, and any existing connections.

GetNATType()

Retrieves the cached NAT type

public NATType GetNATType()

Returns

NATType

The previously cached NAT type.

HasConnection(ProductUserId, string)

Checks if a connection exists to a given remote user

public bool HasConnection(ProductUserId remoteUserId, string socketName)

Parameters

remoteUserId ProductUserId

The id of the remote user to check for.

socketName string

The name of the socket to check for connections on.

Returns

bool

true if a connection exists, false if not.

Initialize()

Initializes the EOS P2P Manager.

public bool Initialize()

Returns

bool

true if the initialization was successful, false if not.

IsValidSocketName(string)

Checks if the given socket name is valid. Socket names may only contain 1-32 alphanumeric characters.

public static bool IsValidSocketName(string name)

Parameters

name string

The socket name to check.

Returns

bool

true if the socket name is valid, false if not.

OnLoggedIn()

To be called after the local user is logged into EOS.

public void OnLoggedIn()

OnLoggedOut()

To be called before the local user is logged out of EOS.

public void OnLoggedOut()

OpenConnection(ProductUserId, string)

Opens (requests/accepts) a named socket connection with a remote peer. EOS supports a limited number of open connections with any individual remote peer (see MaxConnections).

public bool OpenConnection(ProductUserId remoteUserId, string socketName)

Parameters

remoteUserId ProductUserId

The id of the remote peer to open a connection with.

socketName string

The name of the socket to open the connection on.

Returns

bool

true if a connection was requested, a pending connection request was successfully accepted, or the connection has already been locally opened (this case will log a warning), otherwise false.

QueryNATType()

Refreshes our cached NATType (async), which can then be retrieved immediately using GetNATType.

public void QueryNATType()

SendPacket(ProductUserId, string, ArraySegment<byte>, byte, bool, PacketReliability)

Sends a packet to a given remote user on an open connection using the specified reliability.

public void SendPacket(ProductUserId remoteUserId, string socketName, ArraySegment<byte> packet, byte channel = 0, bool allowDelayedDelivery = false, PacketReliability reliability = null)

Parameters

remoteUserId ProductUserId

The id of the remote user to send a packet to.

socketName string

The name of the socket the connection is open on.

packet ArraySegment<byte>

The packet to be sent.

channel byte

Which channel the packet should be sent on.

allowDelayedDelivery bool

If false and there is not an existing connection to the peer, the data will be dropped.

reliability PacketReliability

Which level of reliability the packet should be sent with.

SendPacket(ProductUserId, string, byte[], byte, bool, PacketReliability)

Sends a packet to a given remote user on an open connection using the specified reliability.

public void SendPacket(ProductUserId remoteUserId, string socketName, byte[] packet, byte channel = 0, bool allowDelayedDelivery = false, PacketReliability reliability = null)

Parameters

remoteUserId ProductUserId

The id of the remote user to send a packet to.

socketName string

The name of the socket the connection is open on.

packet byte[]

The packet to be sent.

channel byte

Which channel the packet should be sent on.

allowDelayedDelivery bool

If false and there is not an existing connection to the peer, the data will be dropped.

reliability PacketReliability

Which level of reliability the packet should be sent with.

Shutdown()

Shuts down the EOS P2P manager if initialized and active.

public void Shutdown()

StartClient()

public bool StartClient()

Returns

bool

StartHost()

public bool StartHost()

Returns

bool

StartServer()

public bool StartServer()

Returns

bool

TryGetConnection(ProductUserId, string, out Connection)

Finds an existing connection to a given remote user if it exists

public bool TryGetConnection(ProductUserId remoteUserId, string socketName, out EOSTransportManager.Connection connection)

Parameters

remoteUserId ProductUserId

The id of the remote user to check for.

socketName string

The name of the socket to check for connections on.

connection EOSTransportManager.Connection

Will contain the connection if it exists, or will be set to null if no connection is found.

Returns

bool

true if a connection exists, false if not.

TryReceivePacket(out ProductUserId, out string, out byte, out byte[])

Tries to recieve a packet from any user.

public bool TryReceivePacket(out ProductUserId remoteUserId, out string socketName, out byte channel, out byte[] packet)

Parameters

remoteUserId ProductUserId

The id of the packet's sender if one was recieved.

socketName string

The socket the packet was sent on if one was recieved.

channel byte

The channel the packet was sent on if one was recieved.

packet byte[]

The packet data if one was recieved.

Returns

bool

true if a packet was recieved, false if not. In the latter case, all parameters will be set to null or 0