예제 #1
0
 public IEnumerator ReConnectTCP(TCPWorkInterface inter)
 {
     while (!inter.Vaild()) // 异常情况则不断检测重新连接
     {
         StartTCPWorker();
         yield return(new WaitForSeconds(5.0f));
     }
 }
예제 #2
0
 static void OnConnSucFunc()
 {
     Debug.Log("OnConnSucFunc");
     if (TCPWorkInterface.onConSucHandler != null)
     {
         TCPWorkInterface.onConSucHandler();
     }
 }
예제 #3
0
    /// <summary>
    /// 连接
    /// </summary>
    /// <param name="state"></param>
    private static void OnConnectState(ConnectState state)
    {
        Debug.Log("Connect Status");
        TCPWorkInterface networkInterface = state.netWorkInterface;

        networkInterface.Connecting = false;
        if (state.success)
        {
            //创建接收线程和发送线程
            networkInterface.StartTCPWorker();
            OnConnSucFunc();
            //启动协程判断网络是否断开(暂时备用 )
            TCPNetWork.GetInstance().StartCoroutine(CheckNetStateLoop(state));
        }
        else
        {
            networkInterface.Close();
            Debug.Log("connect error :" + state.success);
            //  增加检测重连5s一次
        }
    }
예제 #4
0
 private void Awake()
 {
     MsgPool = new MessagePool();
     inter   = new TCPWorkInterface();
 }