예제 #1
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);
    }
예제 #2
0
        public void ExecuteCommand(GameSession session, ProtobufRequestInfo requestInfo)
        {
            GroupInfoDAL groupInfoDAL = new GroupInfoDAL();


            var sendQuitGroup = SendQuitGroup.ParseFrom(requestInfo.Body);

            byte[] resultData  = null;
            var    deluserInfo = new mjuserinfoDAL().GetModel(sendQuitGroup.UserID);
            var    groupInfo   = groupInfoDAL.GetGroupInfoByGroupID(sendQuitGroup.GroupID, deluserInfo.is_band.Value);

            if (groupInfo == null)
            {
                session.Logger.Debug("用户退出不存在朋友圈 关闭连接");
                session.Close();
                return;
            }
            if (groupInfoDAL.GetIsExistenceInGroup(sendQuitGroup.GroupID, sendQuitGroup.UserID, 4) != 1)
            {
                resultData = ReturnQuitGroup.CreateBuilder().SetStatus(1).SetMessage("您不是该圈子的成员!").Build().ToByteArray();
                session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 1091, resultData.Length, requestInfo.MessageNum, resultData)));
                return;
            }
            if (groupInfoDAL.GetIsExistenceApplyStatus(sendQuitGroup.GroupID, sendQuitGroup.UserID, 4) == 1)
            {
                resultData = ReturnQuitGroup.CreateBuilder().SetStatus(1).SetMessage("您已经申请过退出,请等待群主通过!").Build().ToByteArray();
                session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 1091, resultData.Length, requestInfo.MessageNum, resultData)));
            }
            else if (groupInfoDAL.ApplyUsersOutByUserIDTransaction(sendQuitGroup.GroupID, sendQuitGroup.UserID, 4, groupInfo.CreateUserID, true) != 0)
            {
                // groupInfoDAL.DelApplyByUserID(sendQuitGroup.GroupID, sendQuitGroup.UserID);
                //groupInfoDAL.ChangeApplyStatus(sendQuitGroup.GroupID, sendQuitGroup.UserID, 4);
                resultData = ReturnQuitGroup.CreateBuilder().SetStatus(1).SetMessage("申请退出成功,等待群主通过!").Build().ToByteArray();
                session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 1091, resultData.Length, requestInfo.MessageNum, resultData)));
            }
            else
            {
                resultData = ReturnQuitGroup.CreateBuilder().SetStatus(1).SetMessage("申请退出失败!").Build().ToByteArray();
                session.Send(new ArraySegment <byte>(CreateHead.CreateMessage(GameInformationBase.BASEAGREEMENTNUMBER + 1091, resultData.Length, requestInfo.MessageNum, resultData)));
            }
        }