Esempio n. 1
0
        public byte[] UpdateImgInfo(byte[] _data, ClientPeer _client, MainServer _server)
        {
            ImgInfo receive = MessageTool.ProtoBufDataDeSerialize <ImgInfo>(_data);

            receive = new ImgInfo()
            {
                AccountId = _client.GetCurAccount.AccountId,
                ImgId     = receive.ImgId,
                ImgPath   = _client.ImgPathDic[receive.ImgId]
            };
            ImgInfo send = mImgDao.AddOrUpdateImgInfo(_client.MySQLConn, receive, false);

            return(MessageTool.ProtoBufDataSerialize(send));
        }
Esempio n. 2
0
        /// <summary>
        /// 更新人物信息
        /// </summary>
        public byte[] UpdateCharacterListInfo(byte[] _data, ClientPeer _client, MainServer _server)
        {
            CharacterInfo receive = MessageTool.ProtoBufDataDeSerialize <CharacterInfo>(_data);
            CharacterInfo info    = mCharacter.UpdateOrAddCharacter(_client.MySQLConn, receive, false);

            MSGCallBack send = null;

            if (info != null)
            {
                send = new MSGCallBack(ReturnCode.Success);
            }
            else
            {
                send = new MSGCallBack(ReturnCode.Fail);
            }
            return(MessageTool.ProtoBufDataSerialize(send));
        }
        public byte[] Login(byte[] data, ClientPeer client, MainServer server)
        {
            AccountInfo recive = MessageTool.ProtoBufDataDeSerialize <AccountInfo>(data);
            AccountInfo user   = mAccount.VerifyUser(client.MySQLConn, recive.AccountName, recive.Password);

            MSGCallBack msg;

            if (user == null)
            {
                msg = new MSGCallBack(ReturnCode.Fail);
            }
            else
            {
                client.IsOnLine = true;
                client.SetCurAccountData(user);
                msg = new MSGCallBack(ReturnCode.Success);
            }
            return(MessageTool.ProtoBufDataSerialize(msg));
        }
        public byte[] Register(byte[] data, ClientPeer client, MainServer server)
        {
            AccountInfo recive = MessageTool.ProtoBufDataDeSerialize <AccountInfo>(data);

            bool        res = mAccount.GetAccountByAccountId(client.MySQLConn, recive.AccountId);
            MSGCallBack msg;

            if (res)
            {
                msg = new MSGCallBack(ReturnCode.Fail);
            }
            else
            {
                mAccount.AddAccount(client.MySQLConn, recive.AccountId,
                                    recive.AccountName, recive.Password, 1001, client.ImgPathDic[1001]);
                client.IsOnLine = true;
                msg             = new MSGCallBack(ReturnCode.Success);
            }
            return(MessageTool.ProtoBufDataSerialize(msg));
        }
Esempio n. 5
0
        public byte[] JoinRoom(byte[] _data, ClientPeer _client, MainServer _server)
        {
            RoomInfo    roomInfo = MessageTool.ProtoBufDataDeSerialize <RoomInfo>(_data);
            MSGCallBack sendMsg  = null;

            foreach (var room in _server.RoomList)
            {
                if (roomInfo.RoomId == room.GetRoonInfo.RoomId)
                {
                    if (room.GetRoonInfo.TotalNum >= room.GetRoonInfo.PlayerNum)
                    {
                        _server.JoinRoom(_client, room);
                        sendMsg = new MSGCallBack(ReturnCode.Success);
                    }
                    else
                    {
                        sendMsg = new MSGCallBack(ReturnCode.Fail);
                    }
                }
            }
            return(MessageTool.ProtoBufDataSerialize(sendMsg));
        }
Esempio n. 6
0
        public byte[] UpdateInventoryListInfo(byte[] _data, ClientPeer _client, MainServer _server)
        {
            List <InventoryInfo> inv  = MessageTool.ProtoBufDataDeSerialize <List <InventoryInfo> >(_data);
            MSGCallBack          send = null;

            if (!isAdded)
            {
                for (int i = 0; i < inv.Count; i++)
                {
                    mInv.AddOrUpdateInventoryInfo(_client.MySQLConn, inv[i], true);
                }
                isAdded = true;
                send    = new MSGCallBack(ReturnCode.Success);
            }
            else
            {
                for (int i = 0; i < inv.Count; i++)
                {
                    mInv.AddOrUpdateInventoryInfo(_client.MySQLConn, inv[i], false);
                }
                send = new MSGCallBack(ReturnCode.Success);
            }
            return(MessageTool.ProtoBufDataSerialize(send));
        }