public static void onMySqlRespond(string respondData)
    {
        try
        {
            UserInfo_Game userInfo_Game = Newtonsoft.Json.JsonConvert.DeserializeObject <UserInfo_Game>(respondData);
            UserInfo_Game_Manager.addOneData(userInfo_Game);

            // 获取到玩家信息之后找到该玩家所在的房间,给同桌的玩家推送此人的信息
            {
                // 去升级找
                RoomData room = GameUtil.getRoomByUid(userInfo_Game.uid);
                if (room != null)
                {
                    string data = Newtonsoft.Json.JsonConvert.SerializeObject(userInfo_Game);

                    for (int i = 0; i < room.getPlayerDataList().Count; i++)
                    {
                        if ((!room.getPlayerDataList()[i].isOffLine()) && (room.getPlayerDataList()[i].m_uid.CompareTo(userInfo_Game.uid) != 0))
                        {
                            // 发送给客户端
                            PlayService.m_serverUtil.sendMessage(room.getPlayerDataList()[i].m_connId, data);
                        }
                    }
                }
                else
                {
                    // 去斗地主找
                    DDZ_RoomData room_ddz = DDZ_GameUtil.getRoomByUid(userInfo_Game.uid);
                    if (room_ddz != null)
                    {
                        string data = Newtonsoft.Json.JsonConvert.SerializeObject(userInfo_Game);

                        for (int i = 0; i < room_ddz.getPlayerDataList().Count; i++)
                        {
                            if ((!room_ddz.getPlayerDataList()[i].isOffLine()) && (room_ddz.getPlayerDataList()[i].m_uid.CompareTo(userInfo_Game.uid) != 0))
                            {
                                // 发送给客户端
                                PlayService.m_serverUtil.sendMessage(room_ddz.getPlayerDataList()[i].m_connId, data);
                            }
                        }
                    }
                }
            }
        }
        catch (Exception ex)
        {
            TLJ_PlayService.PlayService.log.Error("Request_UserInfo_Game.onMySqlRespond----" + ex.Message + "," + respondData);

            // 客户端参数错误
            //respondJO.Add("code", Convert.ToInt32(TLJCommon.Consts.Code.Code_ParamError));

            // 发送给客户端
            //LogicService.m_serverUtil.sendMessage(connId, respondJO.ToString());
        }
    }
예제 #2
0
    public DDZ_GameBase getGameBase()
    {
        DDZ_RoomData room = DDZ_GameUtil.getRoomByUid(m_uid);

        if (room != null)
        {
            return(room.m_gameBase);
        }

        return(null);
    }
예제 #3
0
    private void SendData(IntPtr connId, string data)
    {
        byte[] bytes     = Encoding.UTF8.GetBytes(data);
        byte[] len       = BitConverter.GetBytes((ushort)bytes.Length);
        byte[] flag      = BitConverter.GetBytes(m_packEndFlag);
        byte[] sendBytes = CombineBytes(flag, CombineBytes(len, bytes));

        //LogUtil.getInstance().addDebugLog($"发送数据长度:{sendBytes.Length},body:{bytes.Length},flag:{flag.Length},data:{data}");

        if (m_tcpServer.Send(connId, sendBytes, sendBytes.Length))
        {
            // 日志
            {
                PlayerData playerData = GameUtil.getPlayerDataByConnId(connId);
                if (playerData != null)
                {
                    RoomData room = GameUtil.getRoomByUid(playerData.m_uid);
                    if (room != null)
                    {
                        LogUtil.getInstance().writeRoomLog(room, "发送消息给客户端:" + data);
                    }
                    else
                    {
                        LogUtil.getInstance().addDebugLog("发送消息给客户端:" + data);
                    }
                }
                else
                {
                    DDZ_PlayerData ddz_playerData = DDZ_GameUtil.getPlayerDataByConnId(connId);
                    if (ddz_playerData != null)
                    {
                        DDZ_RoomData room = DDZ_GameUtil.getRoomByUid(ddz_playerData.m_uid);
                        if (room != null)
                        {
                            LogUtil.getInstance().writeRoomLog(room, "发送消息给客户端:" + data);
                        }
                        else
                        {
                            LogUtil.getInstance().addDebugLog("发送消息给客户端:" + data);
                        }
                    }
                    else
                    {
                        LogUtil.getInstance().addDebugLog("发送消息给客户端:" + data);
                    }
                }
            }
        }
        else
        {
            Debug.WriteLine("发送给客户端失败:" + data);
        }
    }
예제 #4
0
    void timerCallback_offLine(object obj)
    {
        try
        {
            switch ((TimerType)obj)
            {
            case TimerType.TimerType_qiangDizhu:
            {
                DDZ_RoomData room = DDZ_GameUtil.getRoomByUid(m_uid);
                if (room != null)
                {
                    DDZ_TrusteeshipLogic.trusteeshipLogic_QiangDiZhu(room.m_gameBase, room, this);
                }
            }
            break;

            case TimerType.TimerType_jiaBang:
            {
                DDZ_RoomData room = DDZ_GameUtil.getRoomByUid(m_uid);
                if (room != null)
                {
                    DDZ_TrusteeshipLogic.trusteeshipLogic_JiaBang(room.m_gameBase, room, this);
                }
            }
            break;

            case TimerType.TimerType_outPoker:
            {
                DDZ_RoomData room = DDZ_GameUtil.getRoomByUid(m_uid);

                if (room.m_curOutPokerPlayer.m_uid.CompareTo(m_uid) != 0)
                {
                    string str = "DDZ_PlayerData.timerCallback case TimerType.TimerType_outPoker错误:当前出牌人应该是:" + room.m_curOutPokerPlayer.m_uid + ",但是现在出牌倒计时结束的人是:" + m_uid;
                    LogUtil.getInstance().writeRoomLog(room, str);
                    return;
                }

                if (!m_isTuoGuan)
                {
                    m_isTuoGuan = true;
                    changeTuoGuanState();
                }
                DDZ_TrusteeshipLogic.trusteeshipLogic_OutPoker(room.m_gameBase, room, this);
            }
            break;
            }
        }
        catch (Exception ex)
        {
            TLJ_PlayService.PlayService.log.Error("DDZ_PlayerData----" + "timerCallback: " + ex);
        }
    }
예제 #5
0
    public static void doAskCilentReq_IsJoinGame(IntPtr connId, string reqData)
    {
        JObject respondJO = new JObject();

        try
        {
            JObject jo  = JObject.Parse(reqData);
            string  tag = jo.GetValue("tag").ToString();
            string  uid = jo.GetValue("uid").ToString();

            // 逻辑处理
            {
                respondJO.Add("tag", tag);

                // 先去升级里面找
                if (GameUtil.checkPlayerIsInRoom(uid))
                {
                    respondJO.Add("isJoinGame", 1);
                    respondJO.Add("gameRoomType", GameUtil.getRoomByUid(uid).m_gameRoomType);
                }
                // 再去斗地主里面找
                else if (DDZ_GameUtil.checkPlayerIsInRoom(uid))
                {
                    respondJO.Add("isJoinGame", 1);
                    respondJO.Add("gameRoomType", DDZ_GameUtil.getRoomByUid(uid).m_gameRoomType);
                }
                else
                {
                    respondJO.Add("isJoinGame", 0);
                }

                // 发送给客户端
                PlayService.m_serverUtil.sendMessage(connId, respondJO.ToString());
            }
        }
        catch (Exception ex)
        {
            TLJ_PlayService.PlayService.log.Error("NetRespond_IsJoinGame----" + ex.Message);

            // 客户端参数错误
            respondJO.Add("code", Convert.ToInt32(TLJCommon.Consts.Code.Code_ParamError));

            //// 发送给客户端
            //PlayService.m_serverUtil.sendMessage(connId, respondJO.ToString());
        }
    }
예제 #6
0
    void doTask_JoinGame(IntPtr connId, string data)
    {
        try
        {
            JObject jo           = JObject.Parse(data);
            string  tag          = jo.GetValue("tag").ToString();
            string  uid          = jo.GetValue("uid").ToString();
            string  gameroomtype = jo.GetValue("gameroomtype").ToString();
            int     playAction   = Convert.ToInt32(jo.GetValue("playAction"));

            DDZ_RoomData room = null;

            // 检测该玩家是否已经加入房间
            if (DDZ_GameUtil.checkPlayerIsInRoom(uid))
            {
                // 给客户端回复
                {
                    JObject respondJO = new JObject();
                    respondJO.Add("tag", tag);
                    respondJO.Add("playAction", playAction);
                    respondJO.Add("gameRoomType", DDZ_GameUtil.getRoomByUid(uid).m_gameRoomType);
                    respondJO.Add("code", (int)TLJCommon.Consts.Code.Code_CommonFail);

                    // 发送给客户端
                    PlayService.m_serverUtil.sendMessage(connId, respondJO.ToString());
                }

                return;
            }

            lock (m_roomList)
            {
                // 在已有的房间寻找可以加入的房间
                for (int i = 0; i < m_roomList.Count; i++)
                {
                    if ((gameroomtype.CompareTo(m_roomList[i].m_gameRoomType) == 0) && (m_roomList[i].getRoomState() == DDZ_RoomState.RoomState_waiting))
                    {
                        if (m_roomList[i].joinPlayer(new DDZ_PlayerData(connId, uid, false, gameroomtype)))
                        {
                            room = m_roomList[i];
                            break;
                        }
                    }
                }

                // 当前没有房间可加入的话则创建一个新的房间
                if (room == null)
                {
                    room = new DDZ_RoomData(this, gameroomtype);
                    room.joinPlayer(new DDZ_PlayerData(connId, uid, false, gameroomtype));

                    m_roomList.Add(room);

                    LogUtil.getInstance().writeRoomLog(room, "新建比赛场房间:" + room.getRoomId());
                }
            }

            // 加入房间成功,给客户端回复
            {
                JObject respondJO = new JObject();
                respondJO.Add("tag", tag);
                respondJO.Add("playAction", playAction);
                respondJO.Add("gameRoomType", gameroomtype);
                respondJO.Add("code", (int)TLJCommon.Consts.Code.Code_OK);
                respondJO.Add("roomId", room.getRoomId());

                // 发送给客户端
                PlayService.m_serverUtil.sendMessage(connId, respondJO.ToString());
            }

            // 检测房间人数是否可以开赛
            DDZ_GameLogic.checkRoomStartGame(room, tag);
        }
        catch (Exception ex)
        {
            TLJ_PlayService.PlayService.log.Error(m_logFlag + "----" + ":doTask_JoinGame异常:" + ex);
        }
    }