Ejemplo n.º 1
0
 private void RecallNow()
 {
     if (DroneID != 0)
     {
         IGC.SendUnicastMessage(DroneID, "command", "recall");
     }
 }
Ejemplo n.º 2
0
        private void ExecuteCommand()
        {
            Screen.ReadText(Buffer);
            RemoveLinesBefore(Buffer, 1);
            string command = Buffer.ToString().Trim();

            Echo("Command: " + command);
            if (DroneID != 0)
            {
                IGC.SendUnicastMessage(DroneID, "command", command);
            }
        }
Ejemplo n.º 3
0
        // Handle the available messages
        bool  HandleMessages()
        {
            int incomingCount = 1; // keep a count of how many messages we've processed

            do
            {
                Echo("Message " + incomingCount.ToString());

                // check broadcast first, then unicast
                bool bBroadcast = _bListener.HasPendingMessage;
                if (bBroadcast)
                {
                    Echo("Broadcast");
                }
                else
                {
                    Echo("Unicast");
                }
                var msg = _bListener.HasPendingMessage ? _bListener.AcceptMessage() : _uListener.AcceptMessage();


                // information about the received message
                Echo("Received Message");
                Echo(msg.ToString());
                var src = msg.Source;
                Echo("Source=" + src.ToString());
                Echo("Data=" + msg.Data);
                Echo("Tag=" + msg.Tag);


                // we could check to see if the source of the message is still reachable (destroyed, out of range, etc)
                // if(IGC.IsEndpointReachable(msg.Source)) {}

                // If we got a brodcast message, reply with a unicast message to the sender
                if (bBroadcast)
                {
                    if (IGC.SendUnicastMessage <string>(msg.Source, UnicastTag, "Message received by:" + Me.EntityId.ToString()))
                    {
                        Echo("Response Sent");
                    }
                    else
                    {
                        Echo("Error sending response");
                    }
                }
                Echo("----");
                incomingCount++;
            } while (_bListener.HasPendingMessage || _uListener.HasPendingMessage); // Process all pending messages
            return(true);
        }
Ejemplo n.º 4
0
 public void Main(string argument, UpdateType updateSource)
 {
     Echo(updateSource.ToString() + " arg:" + argument);
     if ((updateSource & UpdateType.IGC) > 0)
     {
         if (listener.HasPendingMessage)
         {
             MyIGCMessage message = listener.AcceptMessage();
             if (message.Data is string)
             {
                 Echo(message.Data.ToString());
                 // отправляем ответное сообщение
                 IGC.SendUnicastMessage <string>(message.Source, TAG, "result message");
             }
         }
     }
 }
Ejemplo n.º 5
0
        public void TransmitMessage(long requestSource, long shipID, Hangar dock, string action, bool accepted)
        {
            Dictionary <string, object> messageDict = new Dictionary <string, object>
            {
                //["location"] = dock.GetDockPosition(),
                ["action"]   = action,
                ["accepted"] = accepted
            };
            string message_text;

            if (action.ToLower() == "dock")
            {
                if (accepted)
                {
                    message_text = string.Format(MESSAGE_ACCEPT_REQUEST, dock.name, Me.CubeGrid.CustomName);
                }
                else
                {
                    message_text = MESSAGE_REJECT_REQUEST;
                }
            }
            else
            {
                if (accepted)
                {
                    message_text = MESSAGE_ACCEPT_LEAVE;
                }
                else
                {
                    message_text = MESSAGE_REJECT_LEAVE;
                }
            }
            messageDict["message"] = message_text;
            string message     = EncodeMessage(messageDict);
            string dock_string = (dock != null) ? dock.name : "null";

            Log(shipID, dock_string);
            Echo("TRANSMITTING MESSAGE: " + message);

            IGC.SendUnicastMessage(requestSource, "docking", message);


            //antenna.TransmitMessage(message, MyTransmitTarget.Everyone);
        }
Ejemplo n.º 6
0
        // Handler for the test broadcast messages.
        void TestBroadcastHandler(MyIGCMessage msg)
        {
            // NOTE: called on ALL received messages; not just 'our' tag

            if (msg.Tag != _broadCastTag)
            {
                return; // not our message
            }
            if (msg.Data is string)
            {
                Echo("Received Test Message");
                Echo(" Source=" + msg.Source.ToString("X"));
                Echo(" Data=\"" + msg.Data + "\"");
                Echo(" Tag=" + msg.Tag);

                // Now reply to the sender and let them know we received the message
                IGC.SendUnicastMessage(msg.Source, _unicastTag, "Acknowledge by:" + Me.CustomName);
                Echo(" Reply Sent");
            }
        }
Ejemplo n.º 7
0
 private void SendIGCMessage(long address, string message, string arguments)
 {
     IGC.SendUnicastMessage(address, fileSystemClientTag, message + " " + arguments);
 }
Ejemplo n.º 8
0
 private void SendIGCMessage(long address, string message)
 {
     IGC.SendUnicastMessage(address, fileSystemClientTag, message);
 }
Ejemplo n.º 9
0
 public void Main(string argument, UpdateType updateSource)
 {
     IGC.SendUnicastMessage(_navID, TAG, "R;" + run);
     Echo("unicast sent " + run);
     run = run++ % 4;
 }
Ejemplo n.º 10
0
 /// <summary>
 /// IGC Unicast send a message
 /// </summary>
 /// <param name="targetID"></param>
 /// <param name="tag"></param>
 /// <param name="message"></param>
 void antSend(long targetID, string tag, string message)
 {
     IGC.SendUnicastMessage(targetID, tag, message);
 }