Argon

 view release on metacpan or  search on metacpan

lib/Argon/Message.pm  view on Meta::CPAN

    pri  => $NORMAL,
    info => {thing => ['with', 'data', 'in', 'it']},
  );

  my $reply = $msg->reply(info => '...');
  my $error = $msg->error("some error message");

=head1 DESCRIPTION

Argon protocol messages.

=head1 ATTRIBUTES

=head2 id

Unique identifier for the conversation. Used to track the course of a task from
the client to the manager to the worker and back.

=head2 cmd

The command verb. See L<Argon::Constants/:commands>.

=head2 pri

The message priority. See L<Argon::Constants/:priorities>.

=head2 info

The data payload of the message. May be a string, reference, et al.

=head2 token

Used internally by L<Argon::SecureChannel> to identify message senders.

=head1 METHODS

=head2 failed

Returns true if the C<cmd> is C<$ERROR>.

=head2 denied

Returns true if the C<cmd> is C<$DENY>.

=head2 copy

Returns a shallow copy of the message with a new id and token.

=head2 reply

Returns a copy of the message. Any additional parameters passed are passed
transparently to C<new>.

=head2 error

Returns a new message with the same id, C<cmd> set to C<$ERROR>, and C<info>
set to the supplied error message.

=head2 result

Returns the decoded data playload. If the message is an C<$ERROR> or C<$DENY>,
croaks with C<info> as the error message. If the message is an C<$ACK>, returns
true.

=head2 explain

Returns a formatted string describing the message. Useful for debugging and
logging.

=head1 AUTHOR

Jeff Ober <sysread@fastmail.fm>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2017 by Jeff Ober.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut



( run in 3.713 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )