コード例 #1
0
ファイル: TestClient.cs プロジェクト: theGameShop/Flipper
 /// <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));
     }
 }
コード例 #2
0
ファイル: TestClient.cs プロジェクト: theGameShop/Flipper
        /// <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);
            }
        }
コード例 #3
0
ファイル: ServerPeer.cs プロジェクト: tuita520/Regulus
        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);
                }
            }
        }
コード例 #4
0
ファイル: ServerPeer.cs プロジェクト: kof1016/Regulus
        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);
            }
        }
コード例 #5
0
ファイル: TestClient.cs プロジェクト: theGameShop/Flipper
        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);
        }
コード例 #6
0
ファイル: TestClient.cs プロジェクト: theGameShop/Flipper
        /// <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);
        }
コード例 #7
0
ファイル: TestClient.cs プロジェクト: JerryBian/PhotonSample
 /// <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);
     }
 }
コード例 #8
0
ファイル: TestClient.cs プロジェクト: JerryBian/PhotonSample
 /// <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));
     }
 }
コード例 #9
0
ファイル: TestClient.cs プロジェクト: JerryBian/PhotonSample
        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);
        }