Tom Molesworth
and 1 contributors

NAME

Net::Async::ControlChannel::Server - server implementation for Protocol::ControlChannel using IO::Async

VERSION

version 0.002

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.

incoming_stream

Called internally for each incoming client.

incoming_message

Called internally when we have data from a client.

AUTHOR

Tom Molesworth <cpan@entitymodel.com>

LICENSE

Copyright Tom Molesworth 2012-2013. Licensed under the same terms as Perl itself.