| 1 | package POE::Component::Rendezvous::Publish; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 1 | our $VERSION = '0.01'; | |||||||||
| 7 | |||||||||||
| 8 | 1 | ▶ | use Net::Rendezvous::Publish; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 1 | ▶ | use POE; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 1 | ▶ | use POE::Session; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | |||||||||||
| 13 | 0 | ▶ | sub create { | ||||||||
|
Subroutine
create: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 14 | 0 | my $class = shift; | |||||||||
| 15 | |||||||||||
| 16 | 0 | my $publisher = Net::Rendezvous::Publish->new; | |||||||||
| 17 | 0 | ▶ | return undef unless $publisher; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 18 | |||||||||||
| 19 | 0 | my $self = bless { publisher => $publisher, services => {} }, $class; | |||||||||
| 20 | 0 | $self->add_service( @_ ); | |||||||||
| 21 | |||||||||||
| 22 | 0 | POE::Session->create( | |||||||||
| 23 | object_states => [ | ||||||||||
| 24 | $self => { | ||||||||||
| 25 | _start => '_start_event', | ||||||||||
| 26 | step => '_step_event', | ||||||||||
| 27 | }, | ||||||||||
| 28 | ], | ||||||||||
| 29 | ); | ||||||||||
| 30 | } | ||||||||||
| 31 | |||||||||||
| 32 | |||||||||||
| 33 | 0 | ▶ | sub _start_event { | ||||||||
|
Subroutine
_start_event: not called CC=1 SCAR=6.9
| |||||||||||
| 34 | 0 | my $self = $_[OBJECT]; | |||||||||
| 35 | 0 | my $kern = $_[KERNEL]; | |||||||||
| 36 | |||||||||||
| 37 | 0 | $kern->delay_set( step => 2 ); | |||||||||
| 38 | } | ||||||||||
| 39 | |||||||||||
| 40 | |||||||||||
| 41 | 0 | ▶ | sub _step_event { | ||||||||
|
Subroutine
_step_event: not called CC=1 SCAR=6.9
| |||||||||||
| 42 | 0 | my $self = $_[OBJECT]; | |||||||||
| 43 | 0 | my $kern = $_[KERNEL]; | |||||||||
| 44 | |||||||||||
| 45 | 0 | $kern->delay_set( step => 2 ); | |||||||||
| 46 | 0 | $self->step(); | |||||||||
| 47 | } | ||||||||||
| 48 | |||||||||||
| 49 | |||||||||||
| 50 | 0 | ▶ | sub step { | ||||||||
|
Subroutine
step: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 51 | 0 | my $self = shift; | |||||||||
| 52 | 0 | my $pub = $self->{publisher}; | |||||||||
| 53 | |||||||||||
| 54 | 0 | $pub->step( 0.01 ); | |||||||||
| 55 | } | ||||||||||
| 56 | |||||||||||
| 57 | |||||||||||
| 58 | 0 | ▶ | sub add_service { | ||||||||
|
Subroutine
add_service: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||
| 59 | 0 | my $self = shift; | |||||||||
| 60 | 0 | my $pub = $self->{publisher}; | |||||||||
| 61 | 0 | my %args = @_; | |||||||||
| 62 | |||||||||||
| 63 | 0 | ▶ | return 0 unless $args{name}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 64 | |||||||||||
| 65 | 0 | my $service = $pub->publish( %args ); | |||||||||
| 66 | 0 | ▶ | return 0 unless $service; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 67 | |||||||||||
| 68 | 0 | $self->{$args{name}} = $service; | |||||||||
| 69 | 0 | return 1; | |||||||||
| 70 | } | ||||||||||
| 71 | |||||||||||
| 72 | |||||||||||
| 73 | 1 | 1; | |||||||||
| 74 | __END__ | ||||||||||