Пример #1
0
 private void HandleConnResult()
 {
     isStartConnect = false;
     if (connThread != null)
     {
         connThread.Join();
     }
     connThread = null;
     thread     = null;
     if ((tcp != null) && tcp.Connected)
     {
         Debug.Log("连接成功");
         state = SocketState.Connect;
         StartTcp();
         if (OnConnSuccessCallBack != null)
         {
             OnConnSuccessCallBack();
         }
     }
     else
     {
         Debug.Log("连接失败");
         if (OnConnFailCallBack != null)
         {
             OnConnFailCallBack();
         }
     }
 }
Пример #2
0
 private void StartTcp()
 {
     if (thread == null)
     {
         Debug.Log("为tcp 创建新线程");
         thread = new NetThread();
         thread.Start(this);
     }
 }
Пример #3
0
        /// <summary>
        /// 销毁线程
        /// </summary>
        public void DestoryThread()
        {
            if (tcp != null)
            {
                tcp.Close();
            }

            tcp    = null;
            thread = null;
            if (connThread != null)
            {
                connThread = null;
            }
            state = SocketState.Disconnect;
            Debug.Log("客户端 成功 关掉网络连接");
        }