Message¶
Represents a single message stored in a CPU’s or vessel’s MessageQueue.
The main message content that the sender intended to send can be retrieved using Message:CONTENT attribute. Other suffixes are
automatically added to every message by kOS.
Messages are serializable and thus can be passed along:
// if there is a message in the ship's message queue
// we can forward it to a different CPU
// cpu1
SET CPU2 TO PROCESSOR("cpu2").
CPU2:CONNECTION:SENDMESSAGE(SHIP:MESSAGES:POP).
// cpu2
SET RECEIVED TO CORE:MESSAGES:POP.
PRINT "Original message sent at: " + RECEIVED:CONTENT:SENTAT.
Structure¶
-
structure
Message¶ Suffix Type Description SENTATTimeSpandate this message was sent at RECEIVEDATTimeSpandate this message was received at SENDERVesselorBooleanvessel which has sent this message, or Boolean false if sender vessel is now gone HASSENDERBooleanTests whether or not the sender vessel still exists. CONTENTStructuremessage content
Note
This type is serializable.
-
Message:
SENDER¶ Type: VesselorBooleanVessel which has sent this message, or a boolean false value if the sender vessel no longer exists.
If the sender of the message doesn’t exist anymore (see the explanation for
HASSENDER), this suffix will return a different type altogether. It will be aBoolean(which is false).You can check for this condition either by using the
HASSENDERsuffix, or by checking the:ISTYPEsuffix of the sender to detect if it’s really a vessel or not.
-
Message:
HASSENDER¶ Type: BooleanBecause there can be a delay between when the message was sent and when it was processed by the receiving script, it’s possibile that the vessel that sent the message might not exist anymore. It could have either exploded, or been recovered, or been merged into another vessel via docking. You can check the value of the
:HASSENDERsuffix to find out if the sender of the message is still a valid vessel. IfHASSENDERis false, thenSENDERwon’t give you an object of typeVesseland instead will give you just aBooleanfalse.