| 1 | package Horris::Connection::Plugin::RPC; | ||
| 2 | # ABSTRACT: RPC Plugin on Horris | ||
| 3 | |||
| 4 | |||
| 5 | use Moose; | ||
| 6 | use AnyEvent::MP qw(configure port rcv); | ||
| 7 | use AnyEvent::MP::Global qw(grp_reg); | ||
| 8 | use namespace::clean -except => qw/meta/; | ||
| 9 | extends 'Horris::Connection::Plugin'; | ||
| 10 | with 'MooseX::Role::Pluggable::Plugin'; | ||
| 11 | |||
| 12 | has '+is_enable' => ( | ||
| 13 | default => 0 | ||
| 14 | ); | ||
| 15 | |||
| 16 | after init => sub { | ||
| 17 | my $self = shift; | ||
| 18 | configure nodeid => "eg_receiver", binds => ["*:4040"]; | ||
| 19 | my $port = port; | ||
| 20 | grp_reg eg_receivers => $port; | ||
| 21 | rcv $port, test => sub { | ||
| 22 | my ($data) = @_; | ||
| 23 | $self->connection->irc_privmsg({ | ||
| 24 | channel => '#aanoaa', # for test | ||
| 25 | message => $data | ||
| 26 | }); | ||
| 27 | } | ||
| 28 | }; | ||
| 29 | |||
| 30 | __PACKAGE__->meta->make_immutable; | ||
| 31 | |||
| 32 | 1; | ||
| 33 | |||
| 34 | __END__ |