private void ReConnectFailure(int identiy) { UnityMainThreadDispatcher.Instance.Enqueue(() => { SocketClient client = GetSocketClient(identiy); if (client.ConnectTime >= CONNECT_MAX_NUM) { client.ResetConnectTime(true); LuaHelper.CallLuaFunction(GNETWORK_MODULE, GNETWORK_FUNC_RECONNECT_ERROR, identiy); return; } // 尝试重连判断是否改连接状态下 if (client.ConnectTime == CONNECT_SILENCE_NUM) { if (this.socketIdentiy == identiy) { LuaHelper.CallLuaFunction(GNETWORK_MODULE, GNETWORK_FUNC_WAIT_PROCESS, true); } } // 尝试重新链接 client.ReConnection(); }); }
private void ConnectFailure(int identiy) { UnityMainThreadDispatcher.Instance.Enqueue(() => { LuaHelper.CallLuaFunction(GNETWORK_MODULE, GNETWORK_FUNC_CONNECT_ERROR); }); }
/// <summary> /// 消息处理 /// </summary> public void UpdateReciveMessage() { lock (this.responseQueue) { while (this.responseQueue.Count > 0) { PackageData package = (PackageData)responseQueue.Dequeue(); if (package.msgId == MSG_HEART_ID) { if (heartStartTime == 0) { heartStartTime = TimeUtil.CurrentTimeMillis(); } long endTime = TimeUtil.CurrentTimeMillis(); long useTime = endTime - heartStartTime; heartStartTime = endTime; Debugger.Log("Received heart! time==" + useTime); continue; } //call lua socket LuaHelper.CallLuaFunction(GNETWORK_MODULE, GNETWORK_FUNC_RECEIVE_MESSAGE, package.msgId, package.buffer); } } }
private void CloseConnect(int identiy) { // 关闭连接回调 UnityMainThreadDispatcher.Instance.Enqueue(() => { LuaHelper.CallLuaFunction(GNETWORK_MODULE, GNETWORK_FUNC_DISCONNECT, identiy); }); }
private void ReConnectSucess(int identiy) { UnityMainThreadDispatcher.Instance.Enqueue(() => { SocketClient client = GetSocketClient(identiy); if (client == null) { return; } client.ResetConnectTime(false); LuaHelper.CallLuaFunction(GNETWORK_MODULE, GNETWORK_FUNC_RECONNECT_SUCESS, identiy); }); }
private void ConnectSucess(int identiy) { UnityMainThreadDispatcher.Instance.Enqueue(() => { SocketClient client = GetSocketClient(identiy); if (client == null) { return; } Debugger.Log("==========ConnectToServer sucess ip:" + client.ip + " port:" + client.port + "=================="); // 链接成功标识socket状态 this.socketIdentiy = identiy; LuaHelper.CallLuaFunction(GNETWORK_MODULE, GNETWORK_FUNC_CONNECT_SUCESS); }); }