public Communication(IMyProgrammableBlock pb, IMyIntergridCommunicationSystem igc) { this.igc = igc; broadcastListener = igc.RegisterBroadcastListener(listenerId); unicastListener = igc.UnicastListener; this.pb = pb; }
public bool AddUnicastHandler(Action <MyIGCMessage> handler) { myUnicastListener = gridProgram.IGC.UnicastListener; myUnicastListener.SetMessageCallback(); unicastMessageHandlers.Add(handler); return(true); }
/// <summary> /// Add a unicast handler. /// </summary> /// <param name="handler">The handler for messages when received. Note that this handler will be called with ALL Unicast messages. Always sets a callback handler</param> /// <returns></returns> public bool AddUnicastHandler(Action <MyIGCMessage> handler) { _unicastListener = _gridProgram.IGC.UnicastListener; _unicastListener.SetMessageCallback("UNICAST"); _unicastMessageHandlers.Add(handler); return(true); }
public ConnectionClient(IniWatcher ini, IMyGridTerminalSystem gts, IMyIntergridCommunicationSystem igc, CommandLine commandLine, IProcessManager manager, Action <string> logger) { this.gts = gts; this.igc = igc; this.logger = logger; this.mainProcess = manager.Spawn(this.listen, "cc-listen", period: 5); this.listenerCmd = new CommandLine("Connection client listener", null, this.mainProcess); this.listenerCmd.RegisterCommand(new Command("ac-progress", Command.Wrap(this.progress), "", nArgs: 1)); this.listenerCmd.RegisterCommand(new Command("ac-done", Command.Wrap(this.done), "")); this.listenerCmd.RegisterCommand(new Command("ac-cancel", Command.Wrap(this.serverCancel), "")); this.listenerCmd.RegisterCommand(new Command("ac-ko", Command.Wrap(this.ko), "")); this.listener = this.igc.UnicastListener; ini.Add(this); this.Read(ini); this.addCmds(commandLine); manager.AddOnSave(this.save); if (ini.ContainsKey(SECTION, "state")) { ConnectionState state; Enum.TryParse(ini.Get(SECTION, "state").ToString(), out state); this.State = state; } }
public IGCEmitter OnUnicast(string channel, Action<MyIGCMessage> handler) { this.unicastListener = this.p.IGC.UnicastListener; this.unicastListener.SetMessageCallback(channel); this.AddHandler(channel, handler, this.unicastHandlers); return this; }
public void ListenToEveryDirectMsg(Action <MyIGCMessage> reader) { IMyUnicastListener l = p.IGC.UnicastListener; while (l.HasPendingMessage) { reader(l.AcceptMessage()); } }
/// <summary> /// Add a unicast handler. /// </summary> /// <param name="handler">The handler for messages when received. Note that this handler will be called with ALL Unicast messages. Always sets a callback handler</param> /// <returns></returns> public bool AddUnicastHandler(Action <MyIGCMessage> handler) { _unicastListener = _program.IGC.UnicastListener; _unicastListener.SetMessageCallback("UNICAST"); if (!_unicastMessageHandlers.Contains(handler)) { _unicastMessageHandlers.Add(handler); } return(true); }
public AntennaHandler(Program _program) { parent_program = _program; _myBroadcastListener = parent_program.IGC.RegisterBroadcastListener(_recallRequestTag); _myUnicastListener = parent_program.IGC.UnicastListener; //_myUnicastListener = parent_program.IGC.RegisterBroadcastListener(_responseTag); _myUnicastListener.SetMessageCallback("UNICAST"); _myBroadcastListener.SetMessageCallback(_recallRequestTag); }
//#script begin public ShowCase_Echo() //#ctor { //This is my address. Anyone conneted to same antenna relay as me can send me direct message on this addresss. long myIGCAddress = this.IGC.Me; //This is your unicast listener. You should check your mail so it doesn't go to spam ;) IMyUnicastListener myUnicastListener = this.IGC.UnicastListener; //Let's setup message callback with empty argument myUnicastListener.SetMessageCallback(); }
public IGCEmitter(Program p, bool verbose = false, StringBuilder logs = null) { this.p = p; this.id = this.p.IGC.Me; this.handlers = new Dictionary <string, List <Action <MyIGCMessage> > >(); this.listeners = new Dictionary <string, IMyBroadcastListener>(); this.unicastHandlers = new Dictionary <string, List <Action <MyIGCMessage> > >(); this.receievers = new Dictionary <string, long>(); this.verbose = verbose; this.logs = logs ?? new StringBuilder(""); this.unicastListener = this.p.IGC.UnicastListener; }
public Program() { // Echo some information about 'me' when I'm compiled Echo("Creator."); Echo("Me=" + Me.EntityId.ToString()); Echo(Me.CubeGrid.CustomName); // register a broadcast listener _bListener = IGC.RegisterBroadcastListener(BroadcastTag); // What it listens for _bListener.SetMessageCallback(BroadcastTag); // What it will run the PB with once it has a message // save the unicast listener _uListener = IGC.UnicastListener; _uListener.SetMessageCallback(UnicastTag); // set PB callback argument to be used }
public Program() { textPanel = GridTerminalSystem.GetBlockWithName("Docking Display") as IMyTextPanel; List <IMyCockpit> shipControllers = new List <IMyCockpit>(); GridTerminalSystem.GetBlocksOfType(shipControllers); foreach (IMyCockpit cockpit in shipControllers) { //if cockpit is currently controlled by a player if (cockpit.IsMainCockpit) { for (int i = 0; i < cockpit.SurfaceCount; i++) { IMyTextSurface surface = cockpit.GetSurface(i); if (surface.ContentType == ContentType.TEXT_AND_IMAGE) { textPanel = surface; Echo("FOUND TEXT SUFRACE IN COCKPIT"); textPanel.WriteText("DOCK REQUEST CONTROLLER LOADED"); break; } } break; } } List <IMyRadioAntenna> antennas = new List <IMyRadioAntenna>(); GridTerminalSystem.GetBlocksOfType(antennas); antenna = antennas[0]; Echo(String.Format("ANTENNA FOUND: {0}", antenna.CustomName)); antenna.EnableBroadcasting = true; antenna.AttachedProgrammableBlock = Me.EntityId; listener = IGC.UnicastListener; listener.SetMessageCallback("DOCK_MESSAGE"); Echo("CURRENT STATUS: " + Storage); }
private void ReadDirectMsgs() { // Listen direct messages IMyUnicastListener uniL = p.IGC.UnicastListener; int newRangeRequired = -1; while (uniL.HasPendingMessage) { MyIGCMessage msg = uniL.AcceptMessage(); LOGGER.Debug("Got direct msg"); if (msg.Tag == AutoAntennaRelayManager.TAG_ASK_CHANGE_RANGE) { newRangeRequired = Math.Max((int)msg.Data, newRangeRequired); } } if (newRangeRequired > -1) { SetAntennaRange(newRangeRequired); SendMyInfo(); } }
public Program() { listener = IGC.UnicastListener; listener.SetMessageCallback(ARG_CALLBACK); }