Message::Passing::Role::ConnectionManager - A simple manager for inputs and outputs that need to make network connections.
This role is for components which make network connections, and need to handle the connection not starting, timeouts, disconnects etc.
It provides a simple abstraction for multiple other classes to be able to use the same connection manager, and a notifies
Build and return the connection we're managing, start the connection process.
Your connection should use the API as documented below to achieve notification of connect and disconnect events.
Notify clients that the connection is now ready for use.
Notify clients that the connection is no longer ready for use.
Will cause the connection to be terminated and retried.
To use a connection manager, you should register yourself like this:
$manager->subscribe_to_connect($self);
The manager will call $self->connected($connection) and $self->disconnected() when appropriate.
$self->connected($connection)
$self->disconnected()
If the manager is already connected when you subscribe, it will immediately call back into your connected method, if it is not already connected then this will happen at a later point once the connection is established.
connected
See Message::Passing::Role::HasAConnection for a role to help with dealing with a connection manager.
A Boolean indicating if the connection is currently considered fully connected
The connection object (if we are connected, or connecting currently) - can be undefined if we are during a reconnect timeout.
To install Message::Passing, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Message::Passing
CPAN shell
perl -MCPAN -e shell install Message::Passing
For more information on module installation, please visit the detailed CPAN module installation guide.