How To Establish A TCP Connection
After you obtain the connection endpoint along with encryption keys, you may establish a connection using TCP client as shown below:
When a connection is successfully established, OnCreate is raised. If it fails, OnException is raised.
int heartbeatInterval = 5000; // The default is 5000 milliseconds |
The example below will change connection methods internally if the network is IPv6 enabled.
int heartbeatInterval = 5000; // The default is 5000 milliseconds |
Calling Update Method
C# client needs to call its Update method at a certain interval. For Unity game engine, It needs to be called in Unity’s Update method which is called at every frame.
tcp.Update(); |
How To Terminate A TCP Connection
When successfully disconnected, OnDisconnect will be raised.
tcp.Disconnect(); |