Exemple #1
0
        public JoinRandomGameRequest(IRpcProtocol protocol, OperationRequest operationRequest)
            : base(protocol, operationRequest)
        {
            if (!this.IsValid)
            {
                return;
            }

            // special handling for game properties send by AS3/Flash (Amf3 protocol) clients
            if (protocol.ProtocolType == ProtocolType.Amf3V16 || protocol.ProtocolType == ProtocolType.Json)
            {
                Utilities.ConvertAs3WellKnownPropertyKeys(this.GameProperties, null);
                if (this.GameProperties == null)
                {
                    return;
                }

                var propsCache = new WellKnownProperties();
                this.isValid = propsCache.TryGetProperties(this.GameProperties, out this.errorMessage);
            }

            if (this.IsValid)
            {
                this.CheckQueryData();
            }
        }
Exemple #2
0
        public bool TrySetProperties(Hashtable gameProperties, out bool changed, out string debugMessage)
        {
            changed = false;

            byte?maxPlayer;
            bool?isOpen;
            bool?isVisible;

            if (!WellKnownProperties.TryGetProperties(gameProperties, out maxPlayer, out isOpen, out isVisible, out debugMessage))
            {
                return(false);
            }

            if (maxPlayer.HasValue && maxPlayer.Value != this.MaxPlayer)
            {
                this.MaxPlayer = maxPlayer.Value;
                this.properties[(byte)GameParameter.MaxPlayers] = this.MaxPlayer;
                changed = true;
            }

            if (isOpen.HasValue && isOpen.Value != this.IsOpen)
            {
                this.IsOpen = isOpen.Value;
                this.properties[(byte)GameParameter.IsOpen] = isOpen.Value;
                changed = true;
            }

            if (isVisible.HasValue && isVisible.Value != this.IsVisible)
            {
                this.IsVisible = isVisible.Value;
                changed        = true;
            }

            this.properties.Clear();
            foreach (DictionaryEntry entry in gameProperties)
            {
                if (entry.Value != null)
                {
                    this.properties[entry.Key] = entry.Value;
                }
            }

            debugMessage    = string.Empty;
            this.IsJoinable = this.CheckIsGameJoinable();
            return(true);
        }