private static void _onConnectStatus(ConnectState state) { NetworkInterface networkInterface = state.networkInterface; networkInterface.Connecting = false; if (state.success) { // 创建发送和接收进程开始接收数据 networkInterface.startTcpWorker(); // 启动协程判断网络是否断开 LNetwork.GetInstance().StartCoroutine(CheckNetworkStateLoop(networkInterface)); } else { networkInterface.Close(); UnityEngine.Debug.Log("connect error: " + state.error); } if (NetworkInterface.OnConn != null) { NetworkInterface.OnConn.Invoke(state.success); } //EventDispatcher.Instance.TriggerEvent<bool, NetworkInterface.ConnectState>(EventIdType.ConnectSuccess, state.success, state); }
public void close() { inter.Close(); }