Class EOSTransportManager
- Namespace
- PlayEveryWare.EpicOnlineServices.Samples.Network
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
overrideIdProductUserId
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
1170due 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
OnConnectionOpenedCb
Callback function for opening a connection
public EOSTransportManager.OnConnectionOpenedCallback OnConnectionOpenedCb
Field Value
OnIncomingConnectionRequestedCb
Callback function for incoming connection requests.
public EOSTransportManager.OnIncomingConnectionRequestedCallback OnIncomingConnectionRequestedCb
Field Value
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
FullyOpenConnectionsCount
The number of fully opened connections.
public int FullyOpenConnectionsCount { get; }
Property Value
PendingIncomingConnectionsCount
The number of pending outgoing connections.
public int PendingIncomingConnectionsCount { get; }
Property Value
PendingOutgoingConnectionsCount
The number of pending outgoing connections.
public int PendingOutgoingConnectionsCount { get; }
Property Value
Methods
CloseAllConnections(bool)
Closes all open connections.
public bool CloseAllConnections(bool forceClose = true)
Parameters
forceCloseboolIf 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
trueif all connections were successfully closed,falseif 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
remoteUserIdProductUserIdThe id of the remote user to close all connections with.
forceCloseboolIf 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
trueif all connections with the given remote peer were successfully closed,falseif 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
socketNamestringThe name of the socket to close all connections on.
forceCloseboolIf 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
trueif all connections with the given socket name were successfully closed,falseif 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
remoteUserIdProductUserIdThe id of the remote peer to close connection with.
socketNamestringThe name of the socket the exiting connection is on.
forceCloseboolIf 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
trueif a matching remote peer connection was found and closed,falseif not.
Disconnect(bool)
public void Disconnect(bool discardMessageQueue = false)
Parameters
discardMessageQueuebool
GetDebugString(bool)
Gets a string containing debug information related to the state of the P2P manager.
public string GetDebugString(bool includeConnections = false)
Parameters
includeConnectionsbool
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
remoteUserIdProductUserIdThe id of the remote user to check for.
socketNamestringThe name of the socket to check for connections on.
Returns
- bool
trueif a connection exists,falseif not.
Initialize()
Initializes the EOS P2P Manager.
public bool Initialize()
Returns
- bool
trueif the initialization was successful,falseif 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
namestringThe socket name to check.
Returns
- bool
trueif the socket name is valid,falseif 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
remoteUserIdProductUserIdThe id of the remote peer to open a connection with.
socketNamestringThe name of the socket to open the connection on.
Returns
- bool
trueif 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), otherwisefalse.
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
remoteUserIdProductUserIdThe id of the remote user to send a packet to.
socketNamestringThe name of the socket the connection is open on.
packetArraySegment<byte>The packet to be sent.
channelbyteWhich channel the packet should be sent on.
allowDelayedDeliveryboolIf
falseand there is not an existing connection to the peer, the data will be dropped.reliabilityPacketReliabilityWhich 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
remoteUserIdProductUserIdThe id of the remote user to send a packet to.
socketNamestringThe name of the socket the connection is open on.
packetbyte[]The packet to be sent.
channelbyteWhich channel the packet should be sent on.
allowDelayedDeliveryboolIf
falseand there is not an existing connection to the peer, the data will be dropped.reliabilityPacketReliabilityWhich 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
StartHost()
public bool StartHost()
Returns
StartServer()
public bool StartServer()
Returns
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
remoteUserIdProductUserIdThe id of the remote user to check for.
socketNamestringThe name of the socket to check for connections on.
connectionEOSTransportManager.ConnectionWill contain the connection if it exists, or will be set to null if no connection is found.
Returns
- bool
trueif a connection exists,falseif 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
remoteUserIdProductUserIdThe id of the packet's sender if one was recieved.
socketNamestringThe socket the packet was sent on if one was recieved.
channelbyteThe channel the packet was sent on if one was recieved.
packetbyte[]The packet data if one was recieved.
Returns
- bool
trueif a packet was recieved,falseif not. In the latter case, all parameters will be set tonullor0