Esempio n. 1
0
    /// <summary>
    /// 发送创建房间信息
    /// </summary>
    public void OnCreatRoomClick()
    {
        if (GameInfo.isScoketClose)
        {
            GameInfo.cs.Closed();
        }
        GameInfo.cs.serverType = ServerType.ListServer;
        GameInfo.room_peo      = room_peo;
        GameInfo.gameCount     = count;
        GameInfo.operation     = 1;
        //SendGameOperation sendGameOperation = SendGameOperation.CreateBuilder()
        //    .SetOpenid(GameInfo.OpenID)
        //    .SetUnionid(GameInfo.unionid)
        //    .SetOperation(GameInfo.operation)
        //    .SetRoomID(GameInfo.room_id.ToString())
        //    .Build();
        //byte[] body = sendGameOperation.ToByteArray();
        SendGameOperation sendGameOperation = new SendGameOperation();

        sendGameOperation.openid    = GameInfo.OpenID;
        sendGameOperation.unionid   = GameInfo.unionid;
        sendGameOperation.Operation = GameInfo.operation;
        sendGameOperation.RoomID    = GameInfo.room_id.ToString();
        sendGameOperation.GroupID   = (int)GameInfo.GroupID;
        byte[] body = ProtobufUtility.GetByteFromProtoBuf(sendGameOperation);
        byte[] data = CreateHead.CreateMessage(CreateHead.CSXYNUM + 1020, body.Length, 0, body);
        GameInfo.cs.Send(data);
        GameInfo.isScoketClose   = true;
        createRoomButton.enabled = false;
    }
Esempio n. 2
0
        /// <summary>
        /// 解散牌桌
        /// </summary>
        /// <param name="r"></param>
        /// <param name="messageNum">返回消息号</param>
        /// <param name="type">解散类型</param>
        public void DissolutionRoom(Room r, int messageNum, int type)
        {
            List <mjuser> listuser = Gongyong.mulist.FindAll(u => u.RoomID == r.RoomID);
            var           Returnjs = ReturnAllIdea.CreateBuilder().SetState(1).SetMessgaeType(type);

            byte[] Sdata = Returnjs.Build().ToByteArray();
            //if (Gongyong.userlist.Count == 0)
            //    return;
            foreach (var item in listuser)
            {
                UserInfo user = Gongyong.userlist.Find(u => u.openid == item.Openid);
                if (user != null)
                {
                    //RedisUtility.Get<RedisLoginModel>(RedisUtility.GetKey(GameInformationBase.COMMUNITYUSERLIST, gameOperation.Openid, gameOperation.Unionid));
                    //将用户游戏信息更新
                    RedisUtility.Remove(RedisUtility.GetKey(GameInformationBase.COMMUNITYUSERGAME, user.openid, user.unionid));
                    //RedisUtility.Remove(RedisUtility.GetKey(GameInformationBase.COMMUNITYUSERLIST, user.openid, user.unionid));
                    user.session.TrySend(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 5007, Sdata.Length, messageNum, Sdata)));
                }
            }

            Gongyong.roomlist.Remove(r);
            Gongyong.mulist.RemoveAll(u => u.RoomID == r.RoomID);
            RedisUtility.Remove(RedisUtility.GetKey(GameInformationBase.COMMUNITYROOMINFO, r.RoomID.ToString(), ""));
            new RoomInfoDAL().UpdateEndRoomInfoByRoomInfoID(new RoomInfo {
                RoomInfoID = r.RoomInfoID, EndTime = DateTime.Now, EndStatus = type
            });
        }
Esempio n. 3
0
        public void ExecuteCommand(GameSession session, ProtobufRequestInfo requestInfo)
        {
            var             gameOperation = SendGetRoomCard.ParseFrom(requestInfo.Body);
            RedisLoginModel olduser       = RedisUtility.Get <RedisLoginModel>(RedisUtility.GetKey(GameInformationBase.COMMUNITYUSERLIST, gameOperation.Openid, gameOperation.Unionid));

            if (olduser == null)
            {
                return;
            }
            var info = Gongyong.userlist.First(w => w.openid.Equals(olduser.Openid));

            if (info == null)
            {
                return;
            }
            if (info.Type == 0)
            {
                var msg = ReturnGetRoomCard.CreateBuilder().SetUserRoomCard(RoomCardUtility.GetRoomCard(gameOperation.UserID)).Build().ToByteArray();
                session.TrySend(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 1023, msg.Length, requestInfo.MessageNum, msg)));
            }
            else
            {
                var msg = ReturnGetRoomCard.CreateBuilder().SetUserRoomCard(RoomCardUtility.GetLongBaoNumber(info.unionid)).Build().ToByteArray();
                session.TrySend(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 1023, msg.Length, requestInfo.MessageNum, msg)));
            }
        }
Esempio n. 4
0
        public void ExecuteCommand(GameSession session, ProtobufRequestInfo requestInfo)
        {
            var sendData = SendGroupInfoByGroupID.ParseFrom(requestInfo.Body);
            var userInfo = RedisUtility.Get <RedisUserInfoModel>(RedisUtility.GetKey(GameInformationBase.COMMUNITYUSERINFO, sendData.Openid, sendData.Unionid));

            if (userInfo == null || !userInfo.GroupID.Any(w => w == sendData.GroupID))
            {
                session.Close();
                return;
            }
            GroupInfoDAL groupInfoDAL    = new GroupInfoDAL();
            var          groupInfo       = groupInfoDAL.GetGroupInfoByGroupID(sendData.GroupID, userInfo.Type);
            var          returnGroupInfo = ReturnGroupInfoByGroupID.CreateBuilder();

            if (groupInfo != null)
            {
                var data = returnGroupInfo.SetStatus(1).SetCreateTime(TimeToLong.ConvertDateTimeInt(groupInfo.CreateTime)).SetGroupID(groupInfo.GroupID)
                           .SetGroupName(HttpUtility.UrlDecode(HttpUtility.UrlDecode(groupInfo.GroupName))).SetNikeName(HttpUtility.UrlDecode(HttpUtility.UrlDecode(groupInfo.NikeName))).SetCreateUserID(groupInfo.CreateUserID)
                           .SetGroupNumberPeople(groupInfoDAL.GetGroupPeopleNumber(sendData.GroupID)).Build().ToByteArray();
                session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 1033, data.Length, requestInfo.MessageNum, data)));
            }
            else
            {
                var data = returnGroupInfo.SetStatus(0).Build().ToByteArray();
                session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 1033, data.Length, requestInfo.MessageNum, data)));
            }
        }
Esempio n. 5
0
    /*
     * public  void OnEnterRoomLoaded()
     * {
     *  roomID = int.Parse(roomidStr);
     *  SendAddRoom addRoom = SendAddRoom.CreateBuilder()
     *                         .SetRoomID(roomID)
     *                         .SetOpenid(GameInfo.OpenID)
     *                         .Build();
     *  byte[] body = addRoom.ToByteArray();
     *  byte[] data = CreateHead.CreateMessage(CreateHead.CSXYNUM + 2003, body.Length, 0, body);
     *  Debug.Log("jiaru" + roomID + ",id:" + GameInfo.OpenID);
     *  GameInfo.cs.Send(data);
     *
     *  GameInfo.MJplayers.Clear();//加入房间时,清空字典,以免加入别的房间,数据不对
     *  roomidStr = null;
     * }*/

    //message SendAddRoomOne{
    //required string openid = 1;//用户OPENID
    //required int32 RoomID=2;//房间号}
    /// <summary>
    ///
    /// </summary>
    /// <param name="i"></param>
    public void OnEnterRoomClick()
    {
        if (GameInfo.isScoketClose)
        {
            GameInfo.cs.Closed();
        }
        GameInfo.cs.serverType = ServerType.ListServer;
        roomID           = int.Parse(roomidStr);
        GameInfo.room_id = roomID;
        //2017.8.2添加劉磊 開始
        GameInfo.operation = 2;
        //SendGameOperation sendGameOperation = SendGameOperation.CreateBuilder()
        //    .SetOpenid(GameInfo.OpenID)
        //    .SetUnionid(GameInfo.unionid)
        //    .SetOperation(GameInfo.operation)
        //    .SetRoomID(GameInfo.room_id.ToString())
        //    .Build();
        //byte[] body = sendGameOperation.ToByteArray();

        SendGameOperation sendGameOperation = new SendGameOperation();

        sendGameOperation.openid    = GameInfo.OpenID;
        sendGameOperation.unionid   = GameInfo.unionid;
        sendGameOperation.Operation = GameInfo.operation;
        sendGameOperation.RoomID    = GameInfo.room_id.ToString();
        sendGameOperation.GroupID   = (int)GameInfo.GroupID;
        byte[] body = ProtobufUtility.GetByteFromProtoBuf(sendGameOperation);
        byte[] data = CreateHead.CreateMessage(CreateHead.CSXYNUM + 1020, body.Length, 0, body);
        GameInfo.cs.Send(data);
        GameInfo.isScoketClose = true;
        DebugLog(body);
        //結束
    }
Esempio n. 6
0
    public static int UserHearbeat = 0;//记录心跳异常次数
    /// <summary>
    /// 心跳包
    /// </summary>
    /// <returns></returns>
    public static int Xintiao()
    {
        var hear = new MaintainHeartbeat();

        hear.state    = 1;
        hear.openid   = GameInfo.OpenID;
        hear.userID   = userID;
        hear.Latitude = GameInfo.Latitude;
        if (cs.serverType == ServerType.GameServer)
        {
            hear.RoomID = room_id.ToString();
        }

        byte[] body = ProtobufUtility.GetByteFromProtoBuf(hear);
        byte[] data = CreateHead.CreateMessage(CreateHead.CSXYNUM + 1, body.Length, 0, body);

        try
        {
            GameInfo.cs.Send(data);
            UserHearbeat++;
            return(UserHearbeat);
        }
        catch (Exception ex)
        {
            UserHearbeat++;
            return(UserHearbeat);
        }
    }
Esempio n. 7
0
        private void ConnectionList()
        {
            IPAddress ipaddress;
            EndPoint  point;
            Socket    sc = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            ipaddress = IPAddress.Parse("192.168.2.54");
            point     = new IPEndPoint(ipaddress, int.Parse("2018"));
            sc.Connect(point);
            sc.Blocking = true;
            string    openid = Guid.NewGuid().ToString();
            SendLogin login  = SendLogin.CreateBuilder()
                               .SetOpenid(openid)
                               .SetNickname("测试用户" + openid.Substring(0, 3))
                               .SetSex("1")
                               .SetProvince("贵州")
                               .SetCity("贵阳")
                               .SetHeadimg("http://imgsrc.baidu.com/forum/pic/item/34aa0df3d7ca7bcb1620282fb8096b63f724a8ff.jpg")
                               .SetUnionid(openid)
                               .SetLatitude("0,0")
                               .Build();


            byte[] body = login.ToByteArray();
            byte[] data = CreateHead.CreateMessage(CreateHead.CSXYNUM + 1001, body.Length, 0, body);
            // if (clientSocket.Connected)
            //Connect();
            sc.Send(data);
            ReceiveMessage(sc, openid);
        }
Esempio n. 8
0
    //龙宝登录按钮监听方法
    void LongbaoDenglu()
    {
        if (!agreementTge.isOn)
        {
            FICWaringPanel._instance.Show("请阅读并同意用户协议!");
            return;
        }
        //定位
        GPSManager.instance.StartCrt();
        //如果证书不为空
        if (!string.IsNullOrEmpty(GameInfo.certificate))
        {
            SendLoginPW sendLoginPW = new SendLoginPW();

            sendLoginPW.province    = GameInfo.province;
            sendLoginPW.city        = GameInfo.city;
            sendLoginPW.Latitude    = GameInfo.Latitude;
            sendLoginPW.Certificate = GameInfo.certificate;
            byte[] body = ProtobufUtility.GetByteFromProtoBuf(sendLoginPW);
            byte[] data = CreateHead.CreateMessage(CreateHead.CSXYNUM + 1003, body.Length, 0, body);
            GameInfo.cs.Send(data);
            DisableLoginButtons();
            GameInfo.loginType = LoginType.longbao;
        }
        else
        {
            HideLoginButtons();
            ShowZhanghaoPanel();
        }
    }
Esempio n. 9
0
    //账号密码输入界面-登录按钮监听方法
    void ZhanghaoDenglu()
    {
        if (!agreementTge.isOn)
        {
            FICWaringPanel._instance.Show("请阅读并同意用户协议!");
            return;
        }
        //定位
        GPSManager.instance.StartCrt();
        //SendLoginPW来自于谷歌插件
        SendLoginPW sendLoginPW = new SendLoginPW();

        sendLoginPW.UserAccount = inputUserName.text;
        sendLoginPW.pwd         = inputPasword.text;
        //省份
        sendLoginPW.province = GameInfo.province;
        //城市
        sendLoginPW.city = GameInfo.city;
        //维度
        sendLoginPW.Latitude = GameInfo.Latitude;

        byte[] body = ProtobufUtility.GetByteFromProtoBuf(sendLoginPW);
        byte[] data = CreateHead.CreateMessage(CreateHead.CSXYNUM + 1003, body.Length, 0, body);
        GameInfo.cs.Send(data);
        HideZhanghaoPanel();

        GameInfo.loginType = LoginType.longbao;
    }
Esempio n. 10
0
        public void ExecuteCommand(GameSession session, ProtobufRequestInfo requestInfo)
        {
            if (requestInfo.MessageResNum != 19990)
            {
                session.Close();
                session.Logger.Debug("非法用户请求 " + session.RemoteEndPoint.AddressFamily);
                return;
            }
            var RoomExist = SendRoomExist.ParseFrom(requestInfo.Body);
            var muInfo    = Gongyong.mulist.Find(w => w.Openid.Equals(RoomExist.Openid));

            if (muInfo == null)
            {
                var roomInfo = Gongyong.roomlist.Find(w => w.RoomID == RoomExist.RoomID);
                if (roomInfo != null)
                {
                    Gongyong.roomlist.Remove(roomInfo);
                }
                else
                {
                    RedisUtility.Remove(RedisUtility.GetKey(GameInformationBase.COMMUNITYROOMINFO, RoomExist.RoomID.ToString(), ""));
                }
                RedisUtility.Remove(RedisUtility.GetKey(GameInformationBase.COMMUNITYUSERGAME, RoomExist.Openid, RoomExist.Unionid));
                var data = ReturnRoomExist.CreateBuilder().SetIsExist(0).Build().ToByteArray();
                session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 9902, data.Length, 19990, data)));
            }
            else
            {
                var data = ReturnRoomExist.CreateBuilder().SetIsExist(1).Build().ToByteArray();
                session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 9902, data.Length, 19990, data)));
            }
        }
Esempio n. 11
0
    /// <summary>
    /// 发送礼物表情消息
    /// </summary>
    /// <param name="str">礼物字符串标注("int(语音号),int(发送方位)")</param>
    public void SendProp(string str)
    {
        string[] strs = str.Split(',');
        //GameObject  go =  Instantiate(Resources.Load<GameObject>("Game_GYMJ/Prefabs/prop/" + strs[0]), GameUIGO.transform.Find("Fixed_UI/Heads")) as GameObject;
        // go.GetComponent<RectTransform>().localPosition = GetHeadPos((int)(GameInfo.GetFW(GameInfo.FW)));
        //go.GetComponent<RectTransform>().localScale = Vector3.one;
        //go.GetComponent<Image>().SetNativeSize();
        // go.GetComponent<RectTransform>().DOLocalMove(GetHeadPos(int.Parse(strs[1])), 2);
        //StartCoroutine(PropMove(go));

        //SendVoice sendGameOperation = SendVoice.CreateBuilder()
        //   .SetOpenid(GameInfo.OpenID)
        //   .SetRoomID(GameInfo.room_id)
        //   .SetVoiceNumber(int.Parse(strs[0]))
        //   .SetFWT(GetTrueFw(int.Parse(strs[1])))
        //   .Build();
        //byte[] body = sendGameOperation.ToByteArray();

        SendVoice sendGameOperation = new SendVoice();

        sendGameOperation.openid      = GameInfo.OpenID;
        sendGameOperation.RoomID      = GameInfo.room_id;
        sendGameOperation.VoiceNumber = int.Parse(strs[0]);
        sendGameOperation.FWT         = GetTrueFw(int.Parse(strs[1]));
        byte[] body = ProtobufUtility.GetByteFromProtoBuf(sendGameOperation);
        byte[] data = CreateHead.CreateMessage(CreateHead.CSXYNUM + 8002, body.Length, 0, body);
        Debug.Log(data);
        GameInfo.cs.Send(data);
    }
Esempio n. 12
0
        public void ExecuteCommand(GameSession session, ProtobufRequestInfo requestInfo)
        {
            var loginStr = GetCertStr.ParseFrom(requestInfo.Body);
            var data     = ReturnCertStr.CreateBuilder().SetCertStr(DESEncrypt.Encrypt(loginStr.LoginInfoStr)).Build().ToByteArray();

            session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(11002, data.Length, 100001, data)));
        }
Esempio n. 13
0
        public void ExecuteCommand(GameSession session, ProtobufRequestInfo requestInfo)
        {
            GroupInfoDAL       groupInfoDAL    = new GroupInfoDAL();
            var                sendApplyToJoin = SendApplyToJoin.ParseFrom(requestInfo.Body);
            RedisUserInfoModel user            = RedisUtility.Get <RedisUserInfoModel>(RedisUtility.GetKey(GameInformationBase.COMMUNITYUSERINFO, sendApplyToJoin.Openid, sendApplyToJoin.Unionid));

            if (groupInfoDAL.GetGroupInfoByGroupID(sendApplyToJoin.GroupID, user.Type) == null)
            {
                var returnApplyToJoin = ReturnApplyToJoin.CreateBuilder().SetStatus(0).SetMessage("圈子不存在").Build().ToByteArray();
                session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 1041, returnApplyToJoin.Length, requestInfo.MessageNum, returnApplyToJoin)));
            }
            else if (groupInfoDAL.PlayerApplyRecord(user.UserID, sendApplyToJoin.GroupID, 0) == 1)
            {
                var returnApplyToJoin = ReturnApplyToJoin.CreateBuilder().SetStatus(0).SetMessage("已申请,待群主通过").Build().ToByteArray();
                session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 1041, returnApplyToJoin.Length, requestInfo.MessageNum, returnApplyToJoin)));
            }
            else if (groupInfoDAL.PlayerApplyRecord(user.UserID, sendApplyToJoin.GroupID, 1) == 1 || groupInfoDAL.IsUserInGroup(sendApplyToJoin.GroupID, user.UserID) != 0)
            {
                var returnApplyToJoin = ReturnApplyToJoin.CreateBuilder().SetStatus(0).SetMessage("已再圈子中,请勿重复申请").Build().ToByteArray();
                session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 1041, returnApplyToJoin.Length, requestInfo.MessageNum, returnApplyToJoin)));
            }
            //else if (true)
            //{
            //    var returnApplyToJoin = ReturnApplyToJoin.CreateBuilder().SetStatus(0).SetMessage("已再圈子中,请勿重复申请").Build().ToByteArray();
            //    session.Send(new ArraySegment<byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 1041, returnApplyToJoin.Length, requestInfo.MessageNum, returnApplyToJoin)));
            //}
            else
            {
                groupInfoDAL.ApplyToJoin(sendApplyToJoin.GroupID, user.UserID);
                var returnApplyToJoin = ReturnApplyToJoin.CreateBuilder().SetStatus(1).SetMessage("申请成功").Build().ToByteArray();
                session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 1041, returnApplyToJoin.Length, requestInfo.MessageNum, returnApplyToJoin)));
            }
        }
Esempio n. 14
0
        public void ExecuteCommand(GameSession session, ProtobufRequestInfo requestInfo)
        {
            if (!Gongyong.userlist.Any(w => w.session.SessionID.Equals(session.SessionID)))
            {
                session.Logger.Debug("ReqVoice : 非法连接");
                session.Close();
                return;
            }
            var  sendData = SendVoice.ParseFrom(requestInfo.Body);
            Room r        = Gongyong.roomlist.Find(u => u.RoomID == sendData.RoomID);

            if (r == null)
            {
                return;
            }
            var userList = Gongyong.mulist.FindAll(w => w.RoomID == sendData.RoomID);

            foreach (var item in userList)
            {
                var user  = Gongyong.userlist.FirstOrDefault(w => w.openid == item.Openid);
                var voice = ReturnVoice.CreateBuilder().SetFW(item.ZS_Fw).SetVoiceNumber(sendData.VoiceNumber);
                if (sendData.HasFWT)
                {
                    voice.SetFWT(sendData.FWT);
                }
                var data = voice.Build().ToByteArray();
                user.session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 8003, data.Length, requestInfo.MessageNum, data)));
            }
        }
Esempio n. 15
0
        public void ExecuteCommand(GameSession session, ProtobufRequestInfo requestInfo)
        {
            log4net.ILog log = log4net.LogManager.GetLogger("ColoredConsoleAppender");


            var info = RequestUserInfo.ParseFrom(requestInfo.Body);

            DAL.DAL.Business business = new DAL.DAL.Business();
            //获取用户积分消费卷信息
            IntegralInfo integralInfo = business.GetIntegralInfo(info.UserID);

            byte[] data = null;
            if (integralInfo == null)
            {
                log.Error("用户不存在");
                business.InsertIntegralInfo(info.UserID);
                data = ResponseUserInfo.CreateBuilder().SetUserID(info.UserID).SetRoomCard(0).SetIntegral(0).SetCoupons(0).Build().ToByteArray();
                session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(10041, data.Length, requestInfo.MessageNum, data)));
                session.Close();
                return;
            }
            data = ResponseUserInfo.CreateBuilder().SetUserID(integralInfo.userID).SetRoomCard((int)integralInfo.roomCard).SetIntegral((double)integralInfo.integral).SetCoupons((double)integralInfo.coupons).Build().ToByteArray();
            session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(10041, data.Length, requestInfo.MessageNum, data)));
            session.Close();
            return;
        }
Esempio n. 16
0
        public void ExecuteCommand(GameSession session, ProtobufRequestInfo requestInfo)
        {
            var addLongBao = SendAddLongBao.ParseFrom(requestInfo.Body);

            DAL.DAL.Longbao longbao = new DAL.DAL.Longbao();
            int             state   = 0;

            try
            {
                state = longbao.AddLongBao(addLongBao.UserID, addLongBao.Count, addLongBao.Logging);
            }
            catch (Exception ex)
            {
                MyLogger.Logger.Error(ex);
            }
            if (state == 1)
            {
                var data = ReturnMessage.CreateBuilder().SetState(state).SetMessage("返回成功").Build().ToByteArray();
                session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(11010, data.Length, requestInfo.MessageNum, data)));
                //longbao.AddLongBaoLog(addLongBao.UserID, addLongBao.Logging, count);
                //Console.WriteLine(addLongBao.UserID, addLongBao.Logging, count);
            }
            else
            {
                var data = ReturnMessage.CreateBuilder().SetState(state).SetMessage("返回失败").Build().ToByteArray();
                session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(11010, data.Length, requestInfo.MessageNum, data)));
            }
        }
Esempio n. 17
0
    void SendLobbyInfo(long groupID)
    {
        SendLobbyInfo sendLobbyInfo = new SendLobbyInfo();

        sendLobbyInfo.GroupID = groupID;
        byte[] body = ProtobufUtility.GetByteFromProtoBuf(sendLobbyInfo);
        byte[] data = CreateHead.CreateMessage(CreateHead.CSXYNUM + 1080, body.Length, 0, body);
        GameInfo.cs.Send(data);
    }
Esempio n. 18
0
    /// <summary>
    /// 获取朋友圈信息
    /// </summary>
    void SendGroupInfo()
    {
        SendGroupInfo sendGroupInfo = new SendGroupInfo();

        sendGroupInfo.openid  = GameInfo.OpenID;
        sendGroupInfo.unionid = GameInfo.unionid;
        byte[] body = ProtobufUtility.GetByteFromProtoBuf(sendGroupInfo);
        byte[] data = CreateHead.CreateMessage(CreateHead.CSXYNUM + 1030, body.Length, 0, body);
        GameInfo.cs.Send(data);
    }
Esempio n. 19
0
    void AddServer()
    {
        SendAddServer sendAddServer = new SendAddServer();

        sendAddServer.openid  = GameInfo.OpenID;
        sendAddServer.unionid = GameInfo.unionid;
        byte[] body = ProtobufUtility.GetByteFromProtoBuf(sendAddServer);
        byte[] data = CreateHead.CreateMessage(CreateHead.CSXYNUM + 1011, body.Length, 0, body);
        GameInfo.cs.Send(data);
    }
Esempio n. 20
0
    void SendQuitGroup()
    {
        SendQuitGroup sendQuitGroup = new SendQuitGroup();

        sendQuitGroup.GroupID = (int)groupInfo.GroupID;
        sendQuitGroup.UserID  = GameInfo.userID;
        byte[] body = ProtobufUtility.GetByteFromProtoBuf(sendQuitGroup);
        byte[] data = CreateHead.CreateMessage(CreateHead.CSXYNUM + 1090, body.Length, 0, body);
        GameInfo.cs.Send(data);
    }
Esempio n. 21
0
    /// <summary>
    /// 请求加入圈子
    /// </summary>
    void SendApplyToJoin(int groupID)
    {
        SendApplyToJoin sendApplyToJoin = new SendApplyToJoin();

        sendApplyToJoin.GroupID = groupID;
        sendApplyToJoin.openid  = GameInfo.OpenID;
        sendApplyToJoin.unionid = GameInfo.unionid;
        byte[] body = ProtobufUtility.GetByteFromProtoBuf(sendApplyToJoin);
        byte[] data = CreateHead.CreateMessage(CreateHead.CSXYNUM + 1040, body.Length, 0, body);
        GameInfo.cs.Send(data);
    }
Esempio n. 22
0
    /// <summary>
    /// 根据牌桌信息ID请求牌局信息
    /// </summary>
    public void OnSendGetUserGamePlayback(string str)
    {
        Newss_Pel.SetActive(true);
        keyTemp = str;
        SendGetUserGamePlayback sendGetUserGamePlayback = new SendGetUserGamePlayback();

        sendGetUserGamePlayback.RoomInfoID = str;
        byte[] body = ProtobufUtility.GetByteFromProtoBuf(sendGetUserGamePlayback);
        byte[] data = CreateHead.CreateMessage(CreateHead.CSXYNUM + 9003, body.Length, 0, body);
        GameInfo.cs.Send(data);
    }
Esempio n. 23
0
        public void ExecuteCommand(GameSession session, ProtobufRequestInfo requestInfo)
        {
            var getLongBao = GetLongBaoCount.ParseFrom(requestInfo.Body);

            DAL.DAL.Longbao longbao = new DAL.DAL.Longbao();
            int             count   = longbao.GetLongBaoCount(getLongBao.ID);

            var data = ReturnLongBaoCount.CreateBuilder().SetCount(count).Build().ToByteArray();

            session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(11012, data.Length, requestInfo.MessageNum, data)));
        }
Esempio n. 24
0
    void SendGetRoomCard()
    {
        SendGetRoomCard sendGetRoomCard = new SendGetRoomCard();

        sendGetRoomCard.UserID  = GameInfo.userID;
        sendGetRoomCard.openid  = GameInfo.OpenID;
        sendGetRoomCard.unionid = GameInfo.unionid;
        byte[] body = ProtobufUtility.GetByteFromProtoBuf(sendGetRoomCard);
        byte[] data = CreateHead.CreateMessage(CreateHead.CSXYNUM + 1022, body.Length, 0, body);
        GameInfo.cs.Send(data);
    }
Esempio n. 25
0
    /// <summary>
    /// 发送请求开始游戏
    /// </summary>
    public void SendStart()
    {
        ddzSendStart sendStart = new ddzSendStart();

        sendStart.roomid = DDZData.room_id;
        sendStart.openid = GameInfo.OpenID;
        sendStart.UserID = GameInfo.userID;
        byte[] body = ProtobufUtility.GetByteFromProtoBuf(sendStart);
        byte[] data = CreateHead.CreateMessage(CreateHead.CSXYNUMD + 2007, body.Length, 0, body);
        GameInfo.cs.Send(data);
    }
Esempio n. 26
0
    /// <summary>
    /// 发送加入房间
    /// </summary>
    /// <param name="roomId">房间ID</param>
    public void SendAddRoom(int roomId)
    {
        ddzSendAddRoom sendAddRoom = new ddzSendAddRoom();

        sendAddRoom.roomID   = roomId;
        sendAddRoom.openid   = GameInfo.OpenID;
        sendAddRoom.Latitude = GameInfo.Latitude;
        byte[] body = ProtobufUtility.GetByteFromProtoBuf(sendAddRoom);
        byte[] data = CreateHead.CreateMessage(CreateHead.CSXYNUMD + 2003, body.Length, 0, body);
        GameInfo.cs.Send(data);
    }
Esempio n. 27
0
    /// <summary>
    /// 查看申请记录
    /// </summary>
    void SendApplyRecord(long groupID = 0)
    {
        record = groupID == 0 ?  false : true;
        SendApplyRecord sendApplyRecord = new SendApplyRecord();

        sendApplyRecord.UserID  = (int)GameInfo.userID;
        sendApplyRecord.GroupID = groupID;
        byte[] body = ProtobufUtility.GetByteFromProtoBuf(sendApplyRecord);
        byte[] data = CreateHead.CreateMessage(CreateHead.CSXYNUM + 1060, body.Length, 0, body);
        GameInfo.cs.Send(data);
    }
Esempio n. 28
0
        /// <summary>
        /// 用户退出牌桌
        /// </summary>
        /// <param name="usermj"></param>
        /// <param name="roomID"></param>
        /// <param name="openid"></param>
        /// <param name="messageNum"></param>
        /// <param name="session"></param>
        /// <param name="isExit">是否已退出</param>
        public void UserExit(mjuser usermj, int roomID, string openid, int messageNum, GameSession session, bool isExit = false)
        {
            List <mjuser> listmjuser = Gongyong.mulist.FindAll(u => u.RoomID == roomID);

            ///判断是否该房间是否存在用户
            if (listmjuser.Count <= 0)
            {
                return;
            }

            ///向剩余用户下发推出玩家
            var  returnData = ReturnRemoveUser.CreateBuilder().SetOpenid(openid).SetStatus(1);
            Room r          = Gongyong.roomlist.Find(u => u.RoomID == roomID);

            if (r == null)
            {
                return;
            }
            //判断房间已开始游戏
            if (r.startgame == 1)
            {
                returnData.SetStatus(0);
                byte[] returnbyte = returnData.Build().ToByteArray();
                if (!isExit)
                {
                    session.TrySend(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 5009, returnbyte.Length, messageNum, returnbyte)));
                }
            }
            else
            {
                byte[] returnbyte = returnData.Build().ToByteArray();
                if (isExit)
                {
                    listmjuser.Remove(listmjuser.First(w => w.Openid.Equals(openid)));
                }
                r.listOpenid.Remove(openid);
                foreach (var item in listmjuser)
                {
                    UserInfo user = Gongyong.userlist.Find(u => u.openid == item.Openid);
                    if (user != null && user.session != null)
                    {
                        user.session.TrySend(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 5009, returnbyte.Length, messageNum, returnbyte)));
                    }

                    if (user.openid.Equals(usermj.Openid))
                    {
                        //将用户游戏信息更新
                        RedisUtility.Remove(RedisUtility.GetKey(GameInformationBase.COMMUNITYUSERGAME, user.openid, user.unionid));
                    }
                }
                Gongyong.mulist.Remove(usermj);
            }
        }
Esempio n. 29
0
    /// <summary>
    /// 发送出牌信息
    /// </summary>
    /// <param name="cardsStr">//牌ID集合 中间以,分隔  比如 103,104,105 不传为过牌</param>
    public void SendOutCard(string cardsStr)
    {
        ddzSendOutCard sendOutCard = new ddzSendOutCard();

        sendOutCard.openid   = GameInfo.OpenID;
        sendOutCard.UserID   = GameInfo.userID;
        sendOutCard.FW       = DDZData.fw;
        sendOutCard.cardsStr = cardsStr;
        byte[] body = ProtobufUtility.GetByteFromProtoBuf(sendOutCard);
        byte[] data = CreateHead.CreateMessage(CreateHead.CSXYNUMD + 2011, body.Length, 0, body);
        GameInfo.cs.Send(data);
    }
Esempio n. 30
0
    public void ReconServer()
    {
        GameInfo.cs.Closed();
        SendAddServer sendAddServer = new SendAddServer();

        sendAddServer.openid  = GameInfo.OpenID;
        sendAddServer.unionid = GameInfo.unionid;
        byte[] body = ProtobufUtility.GetByteFromProtoBuf(sendAddServer);
        byte[] data = CreateHead.CreateMessage(CreateHead.CSXYNUM + 1011, body.Length, 0, body);
        GameInfo.cs.Send(data);
        ficSGame.isRecon = true;
    }