| 1 | package Net::Rendezvous::Publish::Service; | ||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use base qw( Class::Accessor::Lvalue ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | __PACKAGE__->mk_accessors(qw( _session _handle name type port domain published )); | |||||||||
| 6 | |||||||||||
| 7 | =head1 NAME | ||||||||||
| 8 | |||||||||||
| 9 | Net::Rendezvous::Publish::Service - a Rendezvous odvertised service | ||||||||||
| 10 | |||||||||||
| 11 | =head1 SYNOPSIS | ||||||||||
| 12 | |||||||||||
| 13 | use Net::Rendezvous::Publish; | ||||||||||
| 14 | my $z = Net::Rendezvous::Publish->new; | ||||||||||
| 15 | # publish a webserver on an odd port | ||||||||||
| 16 | my $service = $z->publish( name => "My Webserver", | ||||||||||
| 17 | type => "_http._tcp", | ||||||||||
| 18 | port => 8231 ); | ||||||||||
| 19 | # handle callbacks for 10 seconds | ||||||||||
| 20 | for (1..100) { $z->step( 0.1 ) } | ||||||||||
| 21 | |||||||||||
| 22 | # stop publishing the service | ||||||||||
| 23 | $service->stop; | ||||||||||
| 24 | |||||||||||
| 25 | =head1 DESCRIPTION | ||||||||||
| 26 | |||||||||||
| 27 | A Net::Rendezvous::Publish::Service represents a service you tried to | ||||||||||
| 28 | publish. | ||||||||||
| 29 | |||||||||||
| 30 | You never create one directly, and instead are handed one by the | ||||||||||
| 31 | publish method. | ||||||||||
| 32 | |||||||||||
| 33 | =head1 METHODS | ||||||||||
| 34 | |||||||||||
| 35 | =head2 stop | ||||||||||
| 36 | |||||||||||
| 37 | Stop advertising the service. | ||||||||||
| 38 | |||||||||||
| 39 | =cut | ||||||||||
| 40 | |||||||||||
| 41 | 0 | ▶ | sub stop { | ||||||||
|
Subroutine
stop: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 42 | 0 | my $self = shift; | |||||||||
| 43 | 0 | $self->_session->_backend->publish_stop( $self->_handle ); | |||||||||
| 44 | 0 | $self->published = 0; | |||||||||
| 45 | } | ||||||||||
| 46 | |||||||||||
| 47 | 0 | ▶ | sub _publish_callback { | ||||||||
|
Subroutine
_publish_callback: not called CC=2 SCAR=17.9
| |||||||||||
| 48 | 0 | my $self = shift; | |||||||||
| 49 | 0 | my $result = shift; | |||||||||
| 50 | 0 | ▶ | $self->published = $result eq 'success' ? 1 : 0; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 51 | } | ||||||||||
| 52 | |||||||||||
| 53 | 1 | 1; | |||||||||
| 54 | |||||||||||
| 55 | __END__ | ||||||||||