Example #1
0
 // FUNC ===================================================================================
 //=========================================================================================
 public void Disconnect()
 {
     if (client == null)
     {
         return;
     }
     try
     {
         client.Dispose();
         client = null;
         CheckSocket();
     }
     catch (Exception error)
     {
         Debug.Log(error);
     }
 }
Example #2
0
        public void CheckSocket()
        {
            if (client == null)
            {
                client = new ClientSocketV2(port, host);

                client.onConnectionStarted += ClientSocket_onConnectionStarted;
                client.onConnectionSuccess += ClientSocket_onConnected;
                client.onConnectionFailed  += ClientSocket_onConnectionFailed;

                client.onReconnectionStarted += ClientSocket_onReconnectionBegin;
                client.onReconnectionLimit   += ClientSocket_onReconnectionLimit;

                client.onDisconnectionSuccess += ClientSocket_onDisconnected;

                client.onMessageReceived += Client_onMessageReceived;
            }
            if (!client.connected)
            {
                client.ConnectToServer();
            }
        }
Example #3
0
 private void OnDestroy()
 {
     client?.Dispose();
     client = null; // чтоб наверняка
 }