public static void doAskCilentReq_RetryJoinGame(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();

            // 逻辑处理
            {
                // 先去升级里面找
                if (GameUtil.checkPlayerIsInRoom(uid))
                {
                    GameLogic.doTask_RetryJoinGame(connId, reqData);
                }
                // 再去斗地主里面找
                else if (DDZ_GameUtil.checkPlayerIsInRoom(uid))
                {
                    DDZ_GameLogic.doTask_RetryJoinGame(connId, reqData);
                }
            }
        }
        catch (Exception ex)
        {
        }
    }
示例#2
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());
        }
    }
示例#3
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);
        }
    }