Ejemplo n.º 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();
            }
        }
Ejemplo n.º 2
0
        public void TestCreateLogEventInfoForOperationStarted()
        {
            var operationStarted = new OperationStarted(
                message: "my message",
                operationName: "operation name",
                tracerName: "tracer name",
                operationKind: OperationKind.Startup,
                operationId: "42",
                severity: Severity.Error);

            var log = NLogAdapter.CreateLogEventInfo(operationStarted);

            log.Properties.All(p => WellKnownProperties.Contains(p.Key.ToString())).Should().BeTrue();
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        public void TestCreateLogEventInfoForOperationResult()
        {
            var operationResult = new OperationResult(
                message: "my message",
                operationName: "operation name",
                tracerName: "tracer name",
                status: OperationStatus.Failure,
                duration: TimeSpan.FromSeconds(1),
                operationKind: OperationKind.Startup,
                exception: new Exception("Message"),
                operationId: "42",
                severity: Severity.Error);

            var log = NLogAdapter.CreateLogEventInfo(operationResult);

            log.Properties.All(p => WellKnownProperties.Contains(p.Key.ToString())).Should().BeTrue();
        }