NAME
Net::Async::ControlChannel::Server - server implementation for Protocol::ControlChannel using IO::Async
VERSION
Version 0.005
SYNOPSIS
use Net::Async::ControlChannel::Server;
use IO::Async::Loop;
my $loop = IO::Async::Loop->new;
my $server = Net::Async::ControlChannel::Server->new(
loop => $loop,
);
$server->subscribe_to_event(
message => sub {
my $ev = shift;
my ($k, $v, $from) = @_;
warn "Server: Had $k => $v from $from\n";
}
);
$server->start;
$loop->run;
DESCRIPTION
Provides the server half for a control channel connection.
METHODS
new
Instantiates the server object. Will not establish the listener, but does expect to receive an IO::Async::Loop as the loop
named parameter.
ACCESSOR METHODS
loop
The IO::Async::Loop instance we're (going to be) attached to.
host
Our host. Will be populated after "start" has been called.
port
Our listening port. Will be populated after "start" has been called.
proto
The Protocol::ControlChannel instance. Mainly for internal use.
clients
All currently-connected clients, as a list.
dispatch
Sends a message to all clients.
Expects two parameters:
$k - the key we're sending
$v - the content (can be a ref, in which case it will be encoded using whichever mechanism has been negotiated with the client)
Returns a Future which will resolve when we think we've delivered to all connected clients.
start
Start the listener. Will return a Future which resolves with our instance once the listening socket is active.
listening
The Future corresponding to the listening connection. Resolves with our instance.
listen_active
Called internally when the listen action is complete.
listen_error
Called when there's an error. Marks "listening" as failed.
incoming_stream
Called internally for each incoming client.
incoming_message
Called internally when we have data from a client.
INHERITED METHODS
- Mixin::Event::Dispatch
-
add_handler_for_event, clear_event_handlers, event_handlers, invoke_event, subscribe_to_event, unsubscribe_from_event
AUTHOR
Tom Molesworth <cpan@entitymodel.com>
LICENSE
Copyright Tom Molesworth 2012-2013. Licensed under the same terms as Perl itself.