- REQUIRED METHODS
- PROVIDED METHODS
Tangence::Stream - base class for
Tangence stream-handling mixins
It provides the basic layer of message serialisation, deserialisation, and dispatching to methods that would handle the messages. Higher level classes are used to wrap this functionallity, and provide implementations of methods to handle the messages received.
When a message is received, it will be passed to a method whose name depends on the code of message received. The name will be
handle_request_, followed by the name of the message code, in uppercase; for example
The following methods are required to be implemented by some class using this mixin.
Write bytes of data to the connected peer.
$data will be a plain perl string.
Invoked on receipt of a given message code.
$token will be some opaque perl scalar value, and
$message will be an instance of Tangence::Message.
The value of the token has no particular meaning, other than to be passed to the
The following methods are provided by this mixin.
Informs the object that the underlying connection has now been closed, and any attachments to
Tangence::ObjectProxy instances should now be dropped.
Informs the object that more data has been read from the underlying connection stream. Whole messages will be removed from the beginning of the
$buffer, which should be passed as a direct scalar (because it will be modified). This method will invoke the required
handle_request_* methods. Any bytes remaining that form the start of a partial message will be left in the buffer.
Serialises a message object to pass to the
tangence_write method, then enqueues a response handler to be invoked when a reply arrives. Takes the following named arguments:
- request => Tangence::Message
The message body
- on_response => CODE
CODE reference to the callback to be invoked when a response to the message is received. It will be passed the response message:
$on_response->( $message )
Serialises a message object to be sent to the
tangence_write method. The
$token value that was passed to the
handle_request_ method ensures that it is sent at the correct position in the stream, to allow the peer to pair it with the corresponding request.
Returns the minor version negotiated by the
MSG_INITED initial message handshake.
Paul Evans <firstname.lastname@example.org>