private string ProcessSingleRequest(RequestItem request) { // Skip prefix "{\"Cmd\":\"AGENTCOMMAND\",\"Arg\":{\"Cmd\":\"" var commandName = request.Message.Substring(36, 10); Log?.WriteLine($"{nameof(Dispatcher)} command prefix: '{commandName}'."); if (commandName.StartsWith("OBSERVE") || commandName.StartsWith("DONOTHING")) // DONOTHING is obsolete. { // Just observe. } else if (commandName.StartsWith("TELEPORT")) // Teleport { var requestShell = m_jsoner.ToObject <SeRequestShell <AgentCommand <MoveCommandArgs> > >(request.Message); m_controller.Teleport(requestShell.Arg.Arg.MoveIndicator); } else if (commandName.StartsWith("MOVE_ROTAT")) // MOVE_ROTATE { var requestShell = m_jsoner.ToObject <SeRequestShell <AgentCommand <MoveAndRotateArgs> > >(request.Message); m_controller.Move(requestShell.Arg.Arg); } else if (commandName.StartsWith("MOVETOWARD")) // TODO(PP): Remove. { var requestShell = m_jsoner.ToObject <SeRequestShell <AgentCommand <MoveCommandArgs> > >(request.Message); var moveCommandArgs = requestShell.Arg.Arg; Log?.WriteLine($"Move indicator: {moveCommandArgs.MoveIndicator}"); m_controller.Move(moveCommandArgs.MoveIndicator, Vector2.Zero, 0.0f); } else if (commandName.StartsWith("INTERACT")) { var requestShell = m_jsoner.ToObject <SeRequestShell <AgentCommand <InteractionArgs> > >(request.Message); m_controller.Interact(requestShell.Arg.Arg); } else { throw new NotImplementedException($"Uknown agent command: {commandName}"); } return(m_jsoner.ToJson(m_observer.GetObservation())); }