public override void SendCommands(List <ComponentGroup> commandComponentGroups, global::Improbable.Worker.Core.Connection connection) { if (!commandComponentGroups[0].IsEmptyIgnoreFilter) { var componentGroup = commandComponentGroups[0]; var commandSenderDataArray = componentGroup.GetComponentDataArray <Generated.Improbable.Gdk.Tests.ComponentsWithNoFields.ComponentWithNoFieldsWithCommands.CommandSenders.Cmd>(); var entityArray = componentGroup.GetEntityArray(); for (var j = 0; j < commandSenderDataArray.Length; j++) { var requests = commandSenderDataArray[j]; for (var k = 0; k < requests.RequestsToSend.Count; k++) { var wrappedCommandRequest = requests.RequestsToSend[k]; var schemaCommandRequest = new global::Improbable.Worker.Core.SchemaCommandRequest(ComponentId, 1); global::Generated.Improbable.Gdk.Tests.ComponentsWithNoFields.Empty.Serialization.Serialize(wrappedCommandRequest.Payload, schemaCommandRequest.GetObject()); var requestId = connection.SendCommandRequest(wrappedCommandRequest.TargetEntityId, new global::Improbable.Worker.Core.CommandRequest(schemaCommandRequest), wrappedCommandRequest.TimeoutMillis, wrappedCommandRequest.AllowShortCircuiting ? ShortCircuitParameters : null); CmdStorage.CommandRequestsInFlight[requestId.Id] = new CommandRequestStore <global::Generated.Improbable.Gdk.Tests.ComponentsWithNoFields.Empty>(entityArray[j], wrappedCommandRequest.Payload, null); } requests.RequestsToSend.Clear(); } } if (!commandComponentGroups[1].IsEmptyIgnoreFilter) { var componentGroup = commandComponentGroups[1]; var commandResponderDataArray = componentGroup.GetComponentDataArray <Generated.Improbable.Gdk.Tests.ComponentsWithNoFields.ComponentWithNoFieldsWithCommands.CommandResponders.Cmd>(); for (var j = 0; j < commandResponderDataArray.Length; j++) { var responses = commandResponderDataArray[j]; for (var k = 0; k < responses.ResponsesToSend.Count; k++) { var wrappedCommandResponse = responses.ResponsesToSend[k]; var requestId = new global::Improbable.Worker.Core.RequestId <IncomingCommandRequest>(wrappedCommandResponse.RequestId); if (wrappedCommandResponse.FailureMessage != null) { // Send a command failure if the string is non-null. connection.SendCommandFailure(requestId, wrappedCommandResponse.FailureMessage); continue; } var schemaCommandResponse = new global::Improbable.Worker.Core.SchemaCommandResponse(ComponentId, 1); global::Generated.Improbable.Gdk.Tests.ComponentsWithNoFields.Empty.Serialization.Serialize(wrappedCommandResponse.Payload.Value, schemaCommandResponse.GetObject()); connection.SendCommandResponse(requestId, new global::Improbable.Worker.Core.CommandResponse(schemaCommandResponse)); } responses.ResponsesToSend.Clear(); } } }
public override void SendCommands(ComponentGroup commandGroup, ComponentSystemBase system, global::Improbable.Worker.Core.Connection connection) { Profiler.BeginSample("ComponentWithNoFieldsWithCommands"); var entityType = system.GetArchetypeChunkEntityType(); { var senderType = system.GetArchetypeChunkComponentType <Improbable.Gdk.Tests.ComponentsWithNoFields.ComponentWithNoFieldsWithCommands.CommandSenders.Cmd>(true); var responderType = system.GetArchetypeChunkComponentType <Improbable.Gdk.Tests.ComponentsWithNoFields.ComponentWithNoFieldsWithCommands.CommandResponders.Cmd>(true); var chunks = commandGroup.CreateArchetypeChunkArray(Allocator.TempJob); foreach (var chunk in chunks) { var entities = chunk.GetNativeArray(entityType); var senders = chunk.GetNativeArray(senderType); var responders = chunk.GetNativeArray(responderType); for (var i = 0; i < senders.Length; i++) { var requests = senders[i].RequestsToSend; var responses = responders[i].ResponsesToSend; if (requests.Count > 0) { foreach (var request in requests) { var schemaCommandRequest = new global::Improbable.Worker.Core.SchemaCommandRequest(ComponentId, 1); global::Improbable.Gdk.Tests.ComponentsWithNoFields.Empty.Serialization.Serialize(request.Payload, schemaCommandRequest.GetObject()); var requestId = connection.SendCommandRequest(request.TargetEntityId, new global::Improbable.Worker.Core.CommandRequest(schemaCommandRequest), request.TimeoutMillis, request.AllowShortCircuiting ? ShortCircuitParameters : null); cmdStorage.CommandRequestsInFlight[requestId.Id] = new CommandRequestStore <global::Improbable.Gdk.Tests.ComponentsWithNoFields.Empty>(entities[i], request.Payload, request.Context, request.RequestId); } requests.Clear(); } if (responses.Count > 0) { foreach (var response in responses) { var requestId = new global::Improbable.Worker.Core.RequestId <IncomingCommandRequest>(response.RequestId); if (response.FailureMessage != null) { // Send a command failure if the string is non-null. connection.SendCommandFailure(requestId, response.FailureMessage); continue; } var schemaCommandResponse = new global::Improbable.Worker.Core.SchemaCommandResponse(ComponentId, 1); global::Improbable.Gdk.Tests.ComponentsWithNoFields.Empty.Serialization.Serialize(response.Payload.Value, schemaCommandResponse.GetObject()); connection.SendCommandResponse(requestId, new global::Improbable.Worker.Core.CommandResponse(schemaCommandResponse)); } responses.Clear(); } } } chunks.Dispose(); } Profiler.EndSample(); }