Exemple #1
0
 /// <summary>
 ///   The log operation response.
 /// </summary>
 /// <param name = "response">
 ///   The response.
 /// </param>
 private static void LogOperationResponse(OperationResponse response)
 {
     foreach (KeyValuePair <byte, object> item in response.Parameters)
     {
         log.DebugFormat(string.Format("{0}({1}): {2}", item.Key, (ParameterKey)item.Key, item.Value));
     }
 }
Exemple #2
0
        /// <summary>
        ///   The on response received.
        /// </summary>
        /// <param name = "client">
        ///   The client.
        /// </param>
        /// <param name = "response">
        ///   The response.
        /// </param>
        private static void OnResponseReceived(TestClient client, OperationResponse response)
        {
            Action <TestClient, OperationResponse> received = ResponseReceived;

            if (received != null)
            {
                received(client, response);
            }
        }
Exemple #3
0
        public void Update()
        {
            while (_NewResponses.Count > 0)
            {
                _UpdateResponses.Enqueue(_NewResponses.Dequeue());
            }

            lock (_Sync)
            {
                while (_NewRequests.Count > 0)
                {
                    _UpdateRequests.Enqueue(_NewRequests.Dequeue());
                }
            }


            if (_UpdateResponses.Count > 0)
            {
                if (true /*(System.DateTime.Now - _UpdateTime).TotalMilliseconds > 20*/)
                {
                    var cmd = _UpdateResponses.Dequeue();

                    if (cmd == null)
                    {
                        System.Diagnostics.Debug.WriteLine("_UpdateResponses cmd == null");
                    }
                    _Fiber.Enqueue(() =>
                    {
                        var command      = cmd;
                        var op           = new Photon.SocketServer.OperationResponse();
                        op.OperationCode = command.Id;

                        var pars = new Dictionary <byte, object>();
                        foreach (var arg in command.Args)
                        {
                            pars.Add(arg.Key, arg.Value);
                        }
                        op.Parameters = pars;
                        SendOperationResponse(op, new Photon.SocketServer.SendParameters());
                    });
                }
            }

            while (_UpdateRequests.Count > 0)
            {
                var cmd = _UpdateRequests.Dequeue();
                if (InvokeMethodEvent != null)
                {
                    InvokeMethodEvent.Invoke(cmd.EntityId, cmd.MethodName, cmd.ReturnId, cmd.MethodParams);
                }
            }
        }
Exemple #4
0
        public void Update()
        {
            while (_NewResponses.Count > 0)
            {
                _UpdateResponses.Enqueue(_NewResponses.Dequeue());
            }

            lock (_Sync)
            {
                while (_NewRequests.Count > 0)
                {
                    _UpdateRequests.Enqueue(_NewRequests.Dequeue());
                }
            }

            if (_UpdateResponses.Count > 0)
            {
                if (true /*(System.DateTime.Now - _UpdateTime).TotalMilliseconds > 20*/)
                {
                    var cmd = _UpdateResponses.Dequeue();

                    if (cmd == null)
                    {
                        System.Diagnostics.Debug.WriteLine("_UpdateResponses cmd == null");
                    }
                    _Fiber.Enqueue(() =>
                    {
                        var command = cmd;
                        var op = new Photon.SocketServer.OperationResponse();
                        op.OperationCode = command.Id;

                        var pars = new Dictionary<byte, object>();
                        foreach (var arg in command.Args)
                        {
                            pars.Add(arg.Key, arg.Value);
                        }
                        op.Parameters = pars;
                        SendOperationResponse(op, new Photon.SocketServer.SendParameters());
                    });
                }
            }

            while (_UpdateRequests.Count > 0)
            {
                var cmd = _UpdateRequests.Dequeue();
                if (InvokeMethodEvent != null )
                    InvokeMethodEvent.Invoke(cmd.EntityId, cmd.MethodName, cmd.ReturnId, cmd.MethodParams);
            }
        }
Exemple #5
0
        public void OnOperationResponse(ExitGames.Client.Photon.OperationResponse operationResponse)
        {
            var response = new OperationResponse {
                OperationCode = operationResponse.OperationCode,
                Parameters    = operationResponse.Parameters,
                ReturnCode    = operationResponse.ReturnCode,
                DebugMessage  = operationResponse.DebugMessage,
            };

            if (log.IsDebugEnabled)
            {
                LogOperationResponse(response);
            }

            this.operationResponseQueue.Enqueue(response);

            OnResponseReceived(this, response);
        }
Exemple #6
0
        /// <summary>
        ///   The wait for operation response.
        /// </summary>
        /// <param name = "millisecodsWaitTime">
        ///   The millisecods wait time.
        /// </param>
        /// <returns>
        ///   the response
        /// </returns>
        public OperationResponse WaitForOperationResponse(int millisecodsWaitTime)
        {
            OperationResponse result = this.operationResponseQueue.Dequeue(millisecodsWaitTime);

            return(result);
        }
Exemple #7
0
 /// <summary>
 ///   The on response received.
 /// </summary>
 /// <param name = "client">
 ///   The client.
 /// </param>
 /// <param name = "response">
 ///   The response.
 /// </param>
 private static void OnResponseReceived(TestClient client, OperationResponse response)
 {
     Action<TestClient, OperationResponse> received = ResponseReceived;
     if (received != null)
     {
         received(client, response);
     }
 }
Exemple #8
0
 /// <summary>
 ///   The log operation response.
 /// </summary>
 /// <param name = "response">
 ///   The response.
 /// </param>
 private static void LogOperationResponse(OperationResponse response)
 {
     foreach (KeyValuePair<byte, object> item in response.Parameters)
     {
         log.DebugFormat(string.Format("{0}({1}): {2}", item.Key, (ParameterKey)item.Key, item.Value));
     }
 }
Exemple #9
0
        public void OnOperationResponse(ExitGames.Client.Photon.OperationResponse operationResponse)
        {
            var response = new OperationResponse {
                    OperationCode = operationResponse.OperationCode,
                    Parameters = operationResponse.Parameters,
                    ReturnCode = operationResponse.ReturnCode,
                    DebugMessage = operationResponse.DebugMessage,
                };

            if (log.IsDebugEnabled)
            {
                LogOperationResponse(response);
            }

            this.operationResponseQueue.Enqueue(response);

            OnResponseReceived(this, response);
        }