void ExecuteMessage(string messageString) { var message = new TerminalMessage(messageString); if (!_controllersByName.ContainsKey(message.ControllerName)) { if (Aos.Node.IsMainNode) { throw new Exception($"no controller \"{message.ControllerName}\""); } _log.Warning($"Can't handle message here, redirecting to main node: {messageString}"); _sender.DispatchMessage(new Tag(Aos.Node.MainNodeId), messageString); return; } var controller = _controllersByName[message.ControllerName]; if (!controller.Actions.ContainsKey(message.ActionName)) { throw new Exception($"{message.ControllerName} has no action {message.ActionName}"); } controller.Actions[message.ActionName] .Do(message.Argument) .Then(x => _log.Debug($"{message.Path} returned {x}")); _log.Debug($"Action executed OK: {messageString}"); }
public IPromise <string> Call(RpcRoute route, string argument) { var message = new RpcMessage { Type = RpcMessageType.ActionRequest, Id = Id(), ControllerName = route.ControllerName, ActionName = route.ActionName, Data = argument, ReturnTag = new Tag(Aos.Node.NodeId) }; var promise = new Promise <string>(); _waitingForResult.Add(message.Id, promise); _sender.DispatchMessage(route.TargetTag, message.ToString()); return(promise); }
void ShipBroadcast(string message, string shipId) { var blocks = new List <IMyProgrammableBlock>(); _gameContext.Grid.GetBlocksOfType(blocks); foreach (var pb in blocks.Where(it => it.CustomName.Contains($"({shipId})"))) { _messageSender.DispatchMessage(pb, message); } }