public void OnCommandResponseSecondCommand(CommandResponseOp <global::Improbable.Gdk.Tests.BlittableTypes.BlittableComponent.Commands.SecondCommand> op) { var requestId = op.RequestId.Id; RequestContext requestContext; if (!RequestIdToRequestContext.TryGetValue(requestId, out requestContext)) { LogDispatcher.HandleLog(LogType.Error, new LogEvent("Entity not found during OnCommandResponse.") .WithField(LoggingUtils.LoggerName, LoggerName) .WithField(LoggingUtils.EntityId, op.EntityId.Id) .WithField(MutableView.Component, "SpatialOSBlittableComponent")); return; } RequestIdToRequestContext.Remove(requestId); Unity.Entities.Entity entity; if (requestContext.EntityId == MutableView.WorkerEntityId) { entity = view.WorkerEntity; } else if (!view.TryGetEntity(requestContext.EntityId, out entity)) { return; } var unityResponsePayload = op.Response.HasValue ? global::Generated.Improbable.Gdk.Tests.BlittableTypes.SecondCommandResponse.ToNative(op.Response.Value.Get().Value) : (global::Generated.Improbable.Gdk.Tests.BlittableTypes.SecondCommandResponse?)null; var outgoingRequest = (SecondCommand.OutgoingRequest)requestContext.Request; var response = new SecondCommand.Response(op.EntityId.Id, op.Message, (CommandStatusCode)op.StatusCode, unityResponsePayload, outgoingRequest.RawRequest); view.AddCommandResponse(entity, response, SecondCommandResponsePool); }
private static void HandlePong( CommandResponseOp <PingResponder.Commands.Ping, Pong> response, Connection connection) { if (response.StatusCode != StatusCode.Success) { StringBuilder logMessageBuilder = new StringBuilder(); logMessageBuilder.Append( String.Format("Received invalid OnCommandResponse for request ID {0} with status code {1} to entity with ID {2}.", response.RequestId, response.StatusCode, response.EntityId)); if (!string.IsNullOrEmpty(response.Message)) { logMessageBuilder.Append(String.Format("The message was \'{0}\'.", response.Message)); } if (!response.Response.HasValue) { logMessageBuilder.Append("The response was missing."); } else { logMessageBuilder.Append( String.Format("The EntityIdResponse ID value was {0}", response.Response.Value)); } connection.SendLogMessage(LogLevel.Warn, LoggerName, logMessageBuilder.ToString()); } else { var workerType = response.Response.Value.workerType; var workerMessage = response.Response.Value.workerMessage; var logMessage = String.Format("New Response: {0} says \"{1}\"", workerType, workerMessage); Console.WriteLine(logMessage); connection.SendLogMessage(LogLevel.Info, LoggerName, logMessage); } }
public void AddResponseToDiff(CommandResponseOp op, ViewDiff diff, CommandMetaData commandMetaData) { global::Improbable.Gdk.Core.Empty?rawResponse = null; if (op.StatusCode == StatusCode.Success) { rawResponse = global::Improbable.Gdk.Core.Empty.Serialization.Deserialize(op.Response.SchemaData.Value.GetObject()); } var internalRequestId = new InternalCommandRequestId(op.RequestId); var commandContext = commandMetaData.GetContext <global::Improbable.Gdk.Core.Empty>(ComponentId, 1, internalRequestId); commandMetaData.RemoveRequest(ComponentId, 1, internalRequestId); var response = new PlayerHeartbeat.ReceivedResponse( commandContext.SendingEntity, new EntityId(op.EntityId), op.Message, op.StatusCode, rawResponse, commandContext.Request, commandContext.Context, commandContext.RequestId); diff.AddCommandResponse(response, ComponentId, 1); }
public void OnCommandSendAndUpdateColorIdResponse(CommandResponseOp <CheckOutColor.Commands.SendAndUpdateColorId> op) { if (op.StatusCode != StatusCode.Success && op.EntityId.Id > 406) // DEBUG { connection.SendLogMessage(LogLevel.Warn, Startup.LoggerName, string.Format("SendAndUpdateColorId to Entity {0} return was not success: {1}", op.EntityId, op.Message)); } }
public override void OnCommandResponse(CommandResponseOp op) { var commandIndex = op.Response.CommandIndex; switch (commandIndex) { default: throw new UnknownCommandIndexException(commandIndex, "ComponentWithNoFieldsWithEvents"); } }
internal void OnCommandResponse(CommandResponseOp op) { if (!componentSpecificDispatchers.TryGetValue(op.Response.ComponentId, out var specificDispatcher)) { throw new UnknownComponentIdException( string.Format(Errors.UnknownComponentIdError, op.GetType(), op.Response.ComponentId)); } specificDispatcher.OnCommandResponse(op); }
public override void OnCommandResponse(CommandResponseOp op) { var commandIndex = op.Response.CommandIndex; switch (commandIndex) { default: throw new UnknownCommandIndexException(commandIndex, "NestedComponent"); } }
public override void OnCommandResponse(CommandResponseOp op) { var commandIndex = op.Response.CommandIndex; switch (commandIndex) { default: throw new UnknownCommandIndexException(commandIndex, "ExhaustiveOptional"); } }
private void OnCommandResponse(CommandResponseOp op) { if (!componentSpecificDispatchers.TryGetValue(op.Response.ComponentId, out var specificDispatcher)) { worker.LogDispatcher.HandleLog(LogType.Error, new LogEvent(UnknownComponentIdError).WithField("Op Type", op.GetType()) .WithField("ComponentId", op.Response.ComponentId)); return; } specificDispatcher.OnCommandResponse(op); }
public static WrappedOp <CommandResponseOp> CreateCommandResponseOp(uint componentId, uint commandIndex, long requestId) { var schemaResponse = new SchemaCommandResponse(componentId, commandIndex); var op = new CommandResponseOp { Response = new CommandResponse(schemaResponse), RequestId = new RequestId <OutgoingCommandRequest>(requestId) }; return(new WrappedOp <CommandResponseOp>(op)); }
public override void OnCommandResponse(CommandResponseOp op) { var commandIndex = op.Response.CommandIndex; switch (commandIndex) { case 1: OnCmdResponse(op); break; default: throw new UnknownCommandIndexException(commandIndex, "ComponentWithNoFieldsWithCommands"); } }
private void OnCmdResponse(CommandResponseOp op) { if (!cmdStorage.CommandRequestsInFlight.TryGetValue(op.RequestId.Id, out var requestBundle)) { throw new InvalidOperationException($"Could not find corresponding request for RequestId {op.RequestId.Id} and command Cmd."); } var entity = requestBundle.Entity; cmdStorage.CommandRequestsInFlight.Remove(op.RequestId.Id); if (!entityManager.Exists(entity)) { LogDispatcher.HandleLog(LogType.Error, new LogEvent(EntityNotFound) .WithField(LoggingUtils.LoggerName, LoggerName) .WithField("Op", "CommandResponseOp - Cmd") .WithField("Component", "Generated.Improbable.Gdk.Tests.ComponentsWithNoFields.ComponentWithNoFieldsWithCommands") ); return; } global::Generated.Improbable.Gdk.Tests.ComponentsWithNoFields.Empty?response = null; if (op.StatusCode == StatusCode.Success) { response = global::Generated.Improbable.Gdk.Tests.ComponentsWithNoFields.Empty.Serialization.Deserialize(op.Response.SchemaData.Value.GetObject()); } List <Generated.Improbable.Gdk.Tests.ComponentsWithNoFields.ComponentWithNoFieldsWithCommands.Cmd.ReceivedResponse> responses; if (entityManager.HasComponent <Generated.Improbable.Gdk.Tests.ComponentsWithNoFields.ComponentWithNoFieldsWithCommands.CommandResponses.Cmd>(entity)) { responses = entityManager.GetComponentData <Generated.Improbable.Gdk.Tests.ComponentsWithNoFields.ComponentWithNoFieldsWithCommands.CommandResponses.Cmd>(entity).Responses; } else { var data = new Generated.Improbable.Gdk.Tests.ComponentsWithNoFields.ComponentWithNoFieldsWithCommands.CommandResponses.Cmd { CommandListHandle = Generated.Improbable.Gdk.Tests.ComponentsWithNoFields.ComponentWithNoFieldsWithCommands.ReferenceTypeProviders.CmdResponsesProvider.Allocate(World) }; responses = data.Responses = new List <Generated.Improbable.Gdk.Tests.ComponentsWithNoFields.ComponentWithNoFieldsWithCommands.Cmd.ReceivedResponse>(); entityManager.AddComponentData(entity, data); } responses.Add(new Generated.Improbable.Gdk.Tests.ComponentsWithNoFields.ComponentWithNoFieldsWithCommands.Cmd.ReceivedResponse(op.EntityId, op.Message, op.StatusCode, response, requestBundle.Request, requestBundle.Context, requestBundle.RequestId)); }
public override void OnCommandResponse(CommandResponseOp op) { var commandIndex = op.Response.CommandIndex; switch (commandIndex) { default: LogDispatcher.HandleLog(LogType.Error, new LogEvent(CommandIndexNotFound) .WithField(LoggingUtils.LoggerName, LoggerName) .WithField(LoggingUtils.EntityId, op.EntityId.Id) .WithField("CommandIndex", commandIndex) .WithField("Component", "Generated.Improbable.Gdk.Tests.ExhaustiveOptional") ); break; } }
public override void OnCommandResponse(CommandResponseOp op) { var commandIndex = op.Response.CommandIndex; switch (commandIndex) { default: LogDispatcher.HandleLog(LogType.Error, new LogEvent(CommandIndexNotFound) .WithField(LoggingUtils.LoggerName, LoggerName) .WithField(LoggingUtils.EntityId, op.EntityId.Id) .WithField("CommandIndex", commandIndex) .WithField("Component", "SpatialOSExhaustiveSingular") ); break; } }
public override void OnCommandResponse(CommandResponseOp op) { var commandIndex = op.CommandIndex; Profiler.BeginSample("ComponentWithNoFieldsWithCommands"); switch (commandIndex) { case 1: OnCmdResponse(op); break; default: throw new UnknownCommandIndexException(commandIndex, "ComponentWithNoFieldsWithCommands"); } Profiler.EndSample(); }
private void CompleteCommand(CommandResponseOp r) { if (!requestsToComplete.TryRemove(r.RequestId, out var completer)) { return; } if (r.StatusCode == StatusCode.Success) { if (!r.Response.SchemaData.HasValue) { throw new ArgumentNullException(nameof(r.Response.SchemaData)); } completer.Complete(new CommandResponses { UserCommand = r }); } else { completer.Fail(r.StatusCode, r.Message); } }
public void AddResponseToDiff(CommandResponseOp op, ViewDiff diff, CommandMetaData commandMetaData) { global::Improbable.TestSchema.SomeType?rawResponse = null; if (op.StatusCode == StatusCode.Success) { rawResponse = global::Improbable.TestSchema.SomeType.Serialization.Deserialize(op.Response.SchemaData.Value.GetObject()); } var commandContext = commandMetaData.GetContext <global::Improbable.TestSchema.SomeType>(ComponentId, 1, op.RequestId); commandMetaData.RemoveRequest(ComponentId, 1, op.RequestId); var response = new BarCommand.ReceivedResponse( commandContext.SendingEntity, new EntityId(op.EntityId), op.Message, op.StatusCode, rawResponse, commandContext.Request, commandContext.Context, commandContext.RequestId); diff.AddCommandResponse(response, ComponentId, 1); }
public void AddResponseToDiff(CommandResponseOp op, ViewDiff diff, CommandMetaDataAggregate commandMetaData) { global::Improbable.Gdk.Tests.ComponentsWithNoFields.Empty?rawResponse = null; if (op.StatusCode == StatusCode.Success) { rawResponse = global::Improbable.Gdk.Tests.ComponentsWithNoFields.Empty.Serialization.Deserialize(op.Response.SchemaData.Value.GetObject()); } var commandContext = commandMetaData.GetContext <global::Improbable.Gdk.Tests.ComponentsWithNoFields.Empty>(ComponentId, 1, op.RequestId); commandMetaData.MarkIdForRemoval(ComponentId, 1, op.RequestId); var response = new Cmd.ReceivedResponse( commandContext.SendingEntity, new EntityId(op.EntityId), op.Message, op.StatusCode, rawResponse, commandContext.Request, commandContext.Context, commandContext.RequestId); diff.AddCommandResponse(response, ComponentId, 1); }
public abstract void OnCommandResponse(CommandResponseOp op);
static void OnExtractResourceResponse(CommandResponseOp <Harvestable.Commands.ExtractResource, ResourceExtractionReponse> op) { commandResponseOps.Enqueue(op); }
public override void OnCommandResponse(CommandResponseOp op) { var commandIndex = op.Response.CommandIndex; throw new UnknownCommandIndexException(commandIndex, "ExhaustiveRepeated"); }
public override void OnCommandResponse(CommandResponseOp op) { var commandIndex = op.Response.CommandIndex; throw new UnknownCommandIndexException(commandIndex, "ComponentWithNoFields"); }
/// <summary> /// This method is required to prevent Unity compiler issues. /// </summary> private Option <TResponse> ExtractResponse <TCommand, TResponse>(Func <ICommandResponse <TCommand>, TResponse> extractResponseFunc, CommandResponseOp <TCommand> op) where TCommand : ICommandMetaclass, new() { return(op.Response.HasValue ? extractResponseFunc(op.Response.Value) : new Option <TResponse>()); }
static void OnChatResponse(CommandResponseOp <Communication.Commands.Chat, ChatMessage> op) => chatMessageResponseOps.Enqueue(op);
static void OnGenerateResourceResponse(CommandResponseOp <Harvestable.Commands.GenerateResource, ResourceGenerationReponse> op) { commandResponseOps.Enqueue(op); }
public override void OnCommandResponse(CommandResponseOp op) { var commandIndex = op.CommandIndex; throw new UnknownCommandIndexException(commandIndex, "Connection"); }
static void OnPingReponse(CommandResponseOp <ClientConnection.Commands.Ping, PingResponse> op) { pingResponseOps.Enqueue(op); }
public override void OnCommandResponse(CommandResponseOp op) { var commandIndex = op.Response.CommandIndex; throw new UnknownCommandIndexException(commandIndex, "ExhaustiveBlittableSingular"); }
private void HandleCommandResponse(CommandResponseOp op) { commandResponseCallbacks.InvokeAll(op); }
public override void OnCommandResponse(CommandResponseOp op) { HasCommandResponseReceived = true; }