Class TCPConnectionManager
Helper class for setting up a TCP based network connection
Namespace: Microsoft.MixedReality.SpectatorView
Assembly: cs.temp.dll.dll
Syntax
public class TCPConnectionManager : MonoBehaviour
Fields
AttemptReconnectWhenClient
If true, socket clients will attempt to reconnect when disconnected.
Declaration
public bool AttemptReconnectWhenClient
Field Value
Type | Description |
---|---|
Boolean |
Properties
HasConnections
Returns true if any server or client connections exist, otherwise false
Declaration
public bool HasConnections { get; }
Property Value
Type | Description |
---|---|
Boolean |
IsConnecting
Returns true if a connection is being attempted, otherwise false
Declaration
public bool IsConnecting { get; }
Property Value
Type | Description |
---|---|
Boolean |
OutputBytesQueued
Returns the number of bytes currently queued for the socketer server
Declaration
public int OutputBytesQueued { get; }
Property Value
Type | Description |
---|---|
Int32 |
Methods
Broadcast(Byte[])
Call to broadcast the provided data to all connected clients/servers
Declaration
public void Broadcast(byte[] data)
Parameters
Type | Name | Description |
---|---|---|
Byte[] | data | data to send |
ConnectTo(String, Int32)
Call to start acting as a client connected to the provided server and port
Declaration
public void ConnectTo(string serverAddress, int port)
Parameters
Type | Name | Description |
---|---|---|
String | serverAddress | server to connect to |
Int32 | port | port to use for communication |
DisconnectAll()
Disconnect all connections
Declaration
public void DisconnectAll()
DoStopListening(ref SocketerClient)
Declaration
protected void DoStopListening(ref SocketerClient listener)
Parameters
Type | Name | Description |
---|---|---|
Socketer |
listener |
OnServerDisconnected(SocketerClient, Int32, String)
Declaration
protected virtual void OnServerDisconnected(SocketerClient client, int sourceId, string clientAddress)
Parameters
Type | Name | Description |
---|---|---|
Socketer |
client | |
Int32 | sourceId | |
String | clientAddress |
StartListening(Int32)
Call to begin acting as a server listening on the provided port
Declaration
public void StartListening(int port)
Parameters
Type | Name | Description |
---|---|---|
Int32 | port | port to listen on |
StopListening()
Call to stop acting as a server
Declaration
public void StopListening()
Events
OnConnected
Called when a client or server connection is established and the connection manager is using the TCP protocol.
Declaration
public event Action<SocketEndpoint> OnConnected
Event Type
Type | Description |
---|---|
Action<Socket |
OnDisconnected
Called when a client or server connection is disconnected and the connection manager is using the TCP protocol.
Declaration
public event Action<SocketEndpoint> OnDisconnected
Event Type
Type | Description |
---|---|
Action<Socket |
OnReceive
Called when a data payload is received
Declaration
public event Action<IncomingMessage> OnReceive
Event Type
Type | Description |
---|---|
Action<Incoming |