Example #1
0
        /// <summary>
        /// 更新房间的自定义内容,这个内容是所有对战玩家都可以更新的,不包括观众
        /// </summary>
        /// <param name="update_range">更新的类型.</param>
        /// <param name="custom_data">更新的内容</param>
        /// <param name="check_data">检查的内容.</param>
        public bool UpdateRoomCustomData(UpdateCustomDataRange update_range, Dictionary <String, byte[]> being_updated_data = null, List <string> being_deleted_data = null, Dictionary <String, byte[]> check_data = null, List <string> check_data_not_exits = null, float timeout = 5)
        {
            if ((being_deleted_data == null || being_deleted_data.Count == 0) && (being_updated_data == null || being_updated_data.Count == 0))
            {
                return(false);
            }

            Room_UpdateRoomCustomData_Request client = new Room_UpdateRoomCustomData_Request();

            client.update_range = (int)update_range;

            if (being_updated_data != null)
            {
                foreach (KeyValuePair <string, byte[]> item in being_updated_data)
                {
                    Pair p = new Pair();
                    p.key   = item.Key;
                    p.value = item.Value;
                    client.being_updated_data.Add(p);
                }
            }

            if (being_deleted_data != null)
            {
                client.being_deleted_data.AddRange(being_deleted_data);
            }

            if (check_data != null)
            {
                foreach (KeyValuePair <string, byte[]> item in being_updated_data)
                {
                    PVPProtobuf.Pair p = new PVPProtobuf.Pair();
                    p.key   = item.Key;
                    p.value = item.Value;
                    client.check_data.Add(p);
                }
            }
            if (check_data_not_exits != null)
            {
                client.check_data_not_exist.AddRange(check_data_not_exits);
            }

            if (_socketClient.SendData <Room_UpdateRoomCustomData_Request> (++this._RequestuestId, MessageTypeId.Room_UpdateRoomCustomData_Request, client))
            {
                this._tcpRequestTimeoutChecker [this._RequestuestId] = new TcpRequestTimeoutChecker(this._RequestuestId, timeout, MessageTypeId.Room_UpdateRoomCustomData_Response);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
        public bool UpdateAppUserInfo(int level = -1, Int64 score = -1, int winTimes = -1, int loseTimes = -1, Dictionary <String, byte[]> being_updated_data = null, List <string> being_deleted_data = null, Dictionary <String, byte[]> check_data = null, List <string> check_data_not_exits = null, float timeout = 5)
        {
            AppUser_UpdateInfo_Request client = new AppUser_UpdateInfo_Request();


            client.level      = level;
            client.score      = score;
            client.win_times  = winTimes;
            client.lose_times = loseTimes;

            if (being_updated_data != null)
            {
                foreach (KeyValuePair <string, byte[]> item in being_updated_data)
                {
                    Pair p = new Pair();
                    p.key   = item.Key;
                    p.value = item.Value;
                    client.being_updated_data.Add(p);
                }
            }

            if (being_deleted_data != null)
            {
                client.being_deleted_data.AddRange(being_deleted_data);
            }

            if (check_data != null)
            {
                foreach (KeyValuePair <string, byte[]> item in being_updated_data)
                {
                    PVPProtobuf.Pair p = new PVPProtobuf.Pair();
                    p.key   = item.Key;
                    p.value = item.Value;
                    client.check_data.Add(p);
                }
            }
            if (check_data_not_exits != null)
            {
                client.check_data_not_exist.AddRange(check_data_not_exits);
            }

            if (_socketClient.SendData <AppUser_UpdateInfo_Request> (++this._RequestuestId, MessageTypeId.AppUser_UpdateInfo_Request, client))
            {
                this._tcpRequestTimeoutChecker [this._RequestuestId] = new TcpRequestTimeoutChecker(this._RequestuestId, timeout, MessageTypeId.AppUser_UpdateInfo_Response);
                return(true);
            }
            else
            {
                return(false);
            }
        }