Ejemplo n.º 1
0
 private void startTCP()
 {
     if (!isStartTcp)
     {
         LogTool.Log("服务器连接成功" + serverPoint);
         asyncTcpClient = new AsyncTcpClient();
         asyncTcpClient.Connet(serverPoint);
         asyncTcpClient.OnReceived += AsyncClientReceived;
         isStartTcp = true;
     }
 }
Ejemplo n.º 2
0
 // Update is called once per frame
 void ClientConnect()
 {
     try
     {
         if (asyncTcpClient != null)
         {
             while (!asyncTcpClient.isConnected && asyncTcpClient.tcpClient.Poll(connectTime, System.Net.Sockets.SelectMode.SelectRead))
             {
                 Loom.DispatchToMainThread(() => asyncTcpClient.Connet());
                 Loom.WaitForSeconds(connectTime);
                 count++;
             }
             if (count > exitTime)
             {
                 count = 0;
                 Loom.DispatchToMainThread(() => closeTCP());
             }
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }