示例#1
0
 internal ReceivedResponse(CreateEntityResponseOp op, Request req, object context, long requestId)
 {
     Op             = op;
     RequestPayload = req;
     Context        = context;
     RequestId      = requestId;
 }
示例#2
0
        public static WrappedOp <CreateEntityResponseOp> CreateCreateEntityResponseOp(long requestId)
        {
            var op = new CreateEntityResponseOp
            {
                RequestId = new RequestId <CreateEntityRequest>(requestId)
            };

            return(new WrappedOp <CreateEntityResponseOp>(op));
        }
示例#3
0
 internal ReceivedResponse(CreateEntityResponseOp op, Request req, object context, long requestId)
 {
     StatusCode     = op.StatusCode;
     Message        = op.Message;
     EntityId       = op.EntityId;
     RequestPayload = req;
     Context        = context;
     RequestId      = requestId;
 }
示例#4
0
 internal ReceivedResponse(CreateEntityResponseOp op, Request req, object context, long requestId)
 {
     StatusCode     = op.StatusCode;
     Message        = op.Message;
     EntityId       = op.EntityId.HasValue ? new EntityId?(new EntityId(op.EntityId.Value)) : null;
     RequestPayload = req;
     Context        = context;
     RequestId      = requestId;
 }
示例#5
0
                internal ReceivedResponse(CreateEntityResponseOp op, Entity sendingEntity, Request req, long requestId)
                {
                    SendingEntity  = sendingEntity;
                    StatusCode     = op.StatusCode;
                    Message        = op.Message;
                    RequestPayload = req;
                    Context        = req.Context;
                    RequestId      = requestId;

                    EntityId = op.EntityId.HasValue
                        ? new EntityId(op.EntityId.Value)
                        : (EntityId?)null;
                }
示例#6
0
 public static void EntityCreateCallback(CreateEntityResponseOp response)
 {
     if (requestIdToBusVehicleIdDict.ContainsKey(response.RequestId))
     {
         if (response.EntityId.HasValue)
         {
             EntityId entityId     = response.EntityId.Value;
             string   busVehicleId = requestIdToBusVehicleIdDict[response.RequestId];
             busVehicleIdToEntityIdDict[busVehicleId] = entityId;
             StaticConnection.SendLogMessage(LogLevel.Info, StaticLogName, "Is A Bus");
         }
         else
         {
             StaticConnection.SendLogMessage(LogLevel.Info, StaticLogName, "Bus was not created");
         }
     }
 }
示例#7
0
        private void CompleteCommand(CreateEntityResponseOp r)
        {
            if (!requestsToComplete.TryRemove(r.RequestId, out var completer))
            {
                return;
            }

            if (r.StatusCode == StatusCode.Success)
            {
                completer.Complete(new CommandResponses {
                    CreateEntity = r
                });
            }
            else
            {
                completer.Fail(r.StatusCode, r.Message);
            }
        }
示例#8
0
        public void OnCreateEntityResponse(CreateEntityResponseOp op)
        {
            CreateEntityRequest request = requestIdToCreateEntityRequest[op.RequestId.Id];

            requestIdToCreateEntityRequest.Remove(op.RequestId.Id);

            Entity entity;

            if (!TryGetEntityFromEntityId(request.SenderEntityId, "CreateEntity", out entity))
            {
                return;
            }

            var response =
                new CreateEntityResponse((CommandStatusCode)op.StatusCode, op.Message, op.EntityId.Value.Id, request);

            view.AddCommandResponse(entity, response, createEntityResponsePool);
        }
示例#9
0
        private void OnCreateEntityResponse(CreateEntityResponseOp op)
        {
            if (!createEntityStorage.CommandRequestsInFlight.TryGetValue(op.RequestId.Id, out var requestBundle))
            {
                worker.LogDispatcher.HandleLog(LogType.Error, new LogEvent(RequestIdNotFound)
                                               .WithField(LoggingUtils.LoggerName, LoggerName)
                                               .WithField("RequestId", op.RequestId.Id)
                                               .WithField("Command Type", "CreateEntity"));
                return;
            }

            var entity = requestBundle.Entity;

            createEntityStorage.CommandRequestsInFlight.Remove(op.RequestId.Id);

            if (!EntityManager.Exists(entity))
            {
                worker.LogDispatcher.HandleLog(LogType.Log, new LogEvent(EntityNotFound)
                                               .WithField(LoggingUtils.LoggerName, LoggerName)
                                               .WithField("Op", "CreateEntityResponseOp")
                                               );
                return;
            }

            List <WorldCommands.CreateEntity.ReceivedResponse> responses;

            if (EntityManager.HasComponent <WorldCommands.CreateEntity.CommandResponses>(entity))
            {
                responses = EntityManager.GetComponentData <WorldCommands.CreateEntity.CommandResponses>(entity)
                            .Responses;
            }
            else
            {
                var data = new WorldCommands.CreateEntity.CommandResponses
                {
                    Handle = WorldCommands.CreateEntity.ResponsesProvider.Allocate(World)
                };
                responses = data.Responses = new List <WorldCommands.CreateEntity.ReceivedResponse>();
                EntityManager.AddComponentData(entity, data);
            }

            responses.Add(
                new WorldCommands.CreateEntity.ReceivedResponse(op, requestBundle.Request, requestBundle.Context));
        }
示例#10
0
 private void HandleCreateEntityResponse(CreateEntityResponseOp op)
 {
     createEntityResponseCallbacks.InvokeAll(op);
 }