/// <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)); } }
/// <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); } }
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); } } }
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); } }
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); }
/// <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); }
/// <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); } }
/// <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)); } }