/// <summary> /// 彻底关掉raknet /// </summary> public void ShutDown() { if (mClient != null && mClient.IsActive() && !string.IsNullOrEmpty(ServerIP)) { Debug.LogFormat("DisConnect Server[{0}]====>[{1}].", this.ClientName, this.ServerIP); //Debug.Log("mClient.CloseConnection 被调用"); mClient.CloseConnection(m_serverAddress, true); } if (mClient != null) { //Debug.Log("mClient.Shutdown 被调用"); mClient.Shutdown(300); } IsStartUp = false; IsConnectedServer = false; }
void _RunRead() { while (!_RequestReadThreadStop) { _packet = _peer.Receive(); while (_packet != null) { ProcessMessage(_packet); _peer.DeallocatePacket(_packet); _packet = _peer.Receive(); } Thread.Sleep(10); } Log.Debug("Thread Stop!"); if (_peer != null && ClientState == RakNetClientState.ConnectOK) { _peer.Shutdown(300); } }
/// <summary> /// 彻底关掉raknet /// </summary> public void ShutDown() { Debug.LogFormat("=====Client ShutDown 1: {0} IP:{1}", ClientName, ServerIP); if (mClient != null && mClient.IsActive() && !string.IsNullOrEmpty(ServerIP) && !(m_serverAddress == null)) { Debug.LogFormat("DisConnect Server[{0}]===2=>[{1}].", this.ClientName, this.ServerIP); //Debug.Log("mClient.CloseConnection 被调用"); mClient.CloseConnection(m_serverAddress, true); } Debug.LogFormat("=====Client ShutDown 2: {0} IP:{1}", ClientName, ServerIP); if (mClient != null) { //Debug.Log("mClient.Shutdown 被调用"); mClient.Shutdown(300); RakPeerInterface.DestroyInstance(mClient); mClient = null; } IsStartUp = false; IsConnectedServer = false; IsConnecting = false; Debug.LogFormat("=====Client ShutDown 3: {0} IP:{1}", ClientName, ServerIP); }