# 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
PRINT "Original message sent at: " + RECEIVED:CONTENT:SENTAT.


## Structure¶

structure Message
Suffix Type Description
SENTAT TimeSpan date this message was sent at
RECEIVEDAT TimeSpan date this message was received at
SENDER Vessel or Boolean vessel which has sent this message, or Boolean false if sender vessel is now gone
HASSENDER Boolean Tests whether or not the sender vessel still exists.
CONTENT Structure message content

Note

This type is serializable.

Message:SENTAT
Type: TimeSpan

Date this message was sent at.

Message:RECEIVEDAT
Type: TimeSpan

Date this message was received at.

Message:SENDER
Type: Vessel or Boolean

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 a Boolean (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: Boolean

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. If HASSENDER is false, then SENDER won’t give you an object of type Vessel and instead will give you just a Boolean false.

Message:CONTENT
Type: Structure

Content of this message.