void connectinInThread() { while (!m_tcpClient.Connect(NetConfig.s_mySqlService_ip, (ushort)NetConfig.s_mySqlService_port, false)) { // 连接数据库服务器失败的话会一直尝试连接 LogUtil.getInstance().addDebugLog("连接数据库服务器失败"); Thread.Sleep(1000); } m_isConnecting = true; LogUtil.getInstance().addDebugLog("连接数据库服务器成功"); // 游戏在线统计 Request_OnlineStatistics.doRequest("", 0, "", true, (int)Request_OnlineStatistics.OnlineStatisticsType.OnlineStatisticsType_clear); // 数据清空 { PVPGameRoomDataScript.clear(); } { // 拉取机器人列表 Request_GetAIList.doRequest(); } return; }
HandleResult OnReceive(TcpClient sender, byte[] bytes) { try { string str = Encoding.UTF8.GetString(bytes, 0, bytes.Length); LogUtil.getInstance().addDebugLog("收到数据库服务器消息:" + str); JObject jo = JObject.Parse(str); string tag = jo.GetValue("tag").ToString(); // 获取游戏内玩家信息 if (tag.CompareTo(TLJCommon.Consts.Tag_UserInfo_Game) == 0) { int connId = Convert.ToInt32(jo.GetValue("connId")); Request_UserInfo_Game.onMySqlRespond(str); } // 获取pvp场次信息 else if (tag.CompareTo(TLJCommon.Consts.Tag_GetPVPGameRoom) == 0) { int connId = Convert.ToInt32(jo.GetValue("connId")); NetRespond_GetPVPGameRoom.onMySqlRespond(connId, str); } // 拉取机器人列表 else if (tag.CompareTo(TLJCommon.Consts.Tag_GetAIList) == 0) { Request_GetAIList.onMySqlRespond(str); } // 使用buff else if (tag.CompareTo(TLJCommon.Consts.Tag_UseBuff) == 0) { int connId = Convert.ToInt32(jo.GetValue("connId")); NetRespond_UseBuff.onMySqlRespond(connId, str); } } catch (Exception ex) { TLJ_PlayService.PlayService.log.Error("MySqlServerUtil.OnReceive----异常:" + ex.Message); } return(HandleResult.Ok); }