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
date this message was sent at
date this message was received at
vessel which has sent this message, or Boolean false if sender vessel is now gone
Tests whether or not the sender vessel still exists.
message content
Note
This type is serializable.
- Message:SENDER¶
-
Vessel 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
HASSENDER
suffix, or by checking the:ISTYPE
suffix of the sender to detect if it’s really a vessel or not.
- Message:HASSENDER¶
- Type
Because 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
:HASSENDER
suffix to find out if the sender of the message is still a valid vessel. IfHASSENDER
is false, thenSENDER
won’t give you an object of typeVessel
and instead will give you just aBoolean
false.