Scroll to navigation

Tirex::Message(3pm) User Contributed Perl Documentation Tirex::Message(3pm)

NAME

Tirex::Message - A message

SYNOPSIS

my $msg = Tirex::Message->new( ... );

DESCRIPTION

Messages are used to exchange requests and replies between different components of the Tirex system.

"On the wire" they consist of several lines (separated by an optional carriage return and a newline). Each line has the form "key=value". No spaces are allowed before or after the key or equals sign.

METHODS

Tirex::Message->new( type => '...', field1key => "field2value", ... )

Create new message. You always need a type for the message, all other fields are optional.

Will croak if there is no type given.

Tirex::Message->new_from_string("type=foo\nbar=baz\n");

Create message object from string.

Tirex::Message->new_from_socket($socket)

Read a datagram from given socket and create new message from it.

$msg->reply([RESULT[, ERRMSG]])

Create new message with reply to old one. If RESULT is not given it defaults to 'ok'. If ERRMSG is given, it is attached to the message.

You can't send a reply to a reply, so if the original message contains a 'result' field, this method croaks.

$msg->serialize()

Serialize this message into a string with lines of the format key=value.

If a value is undefined the field is not added.

$msg->to_s()

Return string version of this message, for instance for debugging. Format is key=value separated by spaces.

If a value is undefined the field is not added.

$msg->send($socket, $dest)

Send message through $socket to $dest.

$msg->to_metatile()

Create metatile from message.

Croaks when the message can't be made into a valid metatile.

$msg->ok()

Is this message a positive reply (contains 'result=ok')?

$msg->unknown_message_type()

Is this an error message for an unknown message type (contains 'result=error_unknown_command')?

2021-10-07 perl v5.32.1