NAME
Stem::Inject - Inject a message into a portal via a socket connection
SYNOPSIS
my $return =
Stem::Inject->inject( to => 'some_cell',
type => 'do_something',
port => 10200,
host => 'localhost',
data => { foo => 1 },
);
# do something with data returned
USAGE
This class contains just one method, inject
, which can be used to inject a single message into a Stem hub, via a known server portal.
This is very useful if you have a synchronous system which needs to communicate with a Stem system via messages.
METHODS
inject
This method is the sole interface provided by this class. It accepts the following parameters:
host (required)
This parameter specifies the host with which to connect.
port (required)
The port with which to connect on the specified host.
to (required)
The address of the cell to which the message should be delivered.
type (required)
The type of the message to be delivered.
cmd
The cmd being given. This is only needed if the message's type is "cmd".
data
The data that the message will carry, if any.
codec
The codec to be used when communicating with the port. This defaults to "Data::Dumper", but be careful to set this to whatever value the receiving port is using.
timeout (defaults to 60)
The amount of time, in seconds, before giving up on message delivery or reply. This is the total amount of time allowed for message delivery and receiving a reply.
wait_for_reply (defaults to true)
If this is true then the
inject
method will expect a reply to the message it delivers. If it doesn't receive one this will be considered an error.
If there is an error in trying to inject a message, either with the parameters given, or with the socket connection, then this method will return an error string.
If no reply was expected, this method simply returns false. Otherwise, it returns the reply message's data, which will always be a reference.
AUTHOR
Dave Rolsky <david@stemsystems.com>