Haiku API Bindings
Messenger
Not logged in

Documentation | ApplicationKit | Messenger

SYNOPSIS

Perl

use HaikuR1::Messenger;

my $messenger = HaikuR1::Messenger->new($handler, $looper);
$messenger->SendMessage($message);

Python

from HaikuR1.ApplicationKit import Messenger

messenger = Messenger(handler, looper)
messenger.SendMessage(message)

DESCRIPTION

Exposes the BMessenger object.

For more information on Messenger, see the Be Book class description, the Be Book overview, and the Haiku Book class description.

METHODS

Constructor

Creates an Messenger with a local target.

Perl

HaikuR1::Messenger->new($param1, $param2);

Python

Messenger(param1, param2)

To target a Looper directly, pass it as param1 (this works because a Looper is also a Handler). To target a Looper's preferred handler, pass the empty value as param1 and the Looper as param2.

If you pass a signature without a team, you target a running team with that signature (assuming such an instance is actually running). If you pass a signature and a team, you will get a valid Messenger only if that team has that signature. If you pass the empty value as param1 and a valid team id as param2, you will target that team no matter what it's signature.

copy

Copies the contents of another object into this object.

Perl

$messenger->copy($copy_from);

Python

messenger.copy(copy_from)

A Messenger to copy.

IsTargetLocal

Returns true if the target is local, false if it is remote or if the Messenger is not valid.

Perl

$messenger->IsTargetLocal();

Python

messenger.IsTargetLocal()

HashValue

Returns a value that is the same if the targets are the same and (probably) different if the targets are different.

Perl

$messenger->HashValue();

Python

messenger.HashValue()

IsValid

Returns true if the Messenger is valid.

Perl

$messenger->IsValid();

Python

messenger.IsValid()

Locking

LockTarget

LockTargetWithTimeout

These methods do what you would expect. They work only on local targets.

LockTarget will block until it obtains a lock. LockTargetWithTimeout may signal an error.

Note that there is no UnlockTarget method.

Locks the target looper (if it is local).

Perl

$messenger->LockTarget();
$messenger->LockTargetWithTimeout($timeout);

Python

messenger.LockTarget()
messenger.LockTargetWithTimeout(timeout)

SendMessage

Sends a Message to the target. Signals an error on failure.

Perl

$messenger->SendMessage(
    message => $message,
    replyTo => $replyTo,
    timeout => $timeout,
    replyTimeout => $replyTimeout,
    synchronous => $synchronous,
);

Python

messenger.SendMessage(
    message = message,
    replyTo = replyTo,
    timeout = timeout,
    replyTimeout = replyTimeout,
    synchronous = synchronous,
)

SetTo

Sets the Messenger to a local target. Signals an error on failure.

Perl

$messenger->SetTo($handler, $looper);

Python

messenger.SetTo(handler, looper)

The parameters have the same effect as for the constructor. (Note: you cannot pass a Messenger as param1, unlike with new.)

Target

Returns the handler and looper that are a local target.

Perl

$messenger->Target();

Python

messenger.Target()

Team

Returns the id of the target team, or signals an error.

Perl

$messenger->Team();

Python

messenger.Team()

OPERATORS

==

Returns true if the Messengers have the same target.

!=

Returns true if the Messengers have different targets.

<

Applies a consistent ordering to Messengers; mainly used internally.