line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Rendezvous::Publish::Service; |
2
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
27
|
|
4
|
1
|
|
|
1
|
|
5
|
use base qw( Class::Accessor::Lvalue ); |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
873
|
|
5
|
|
|
|
|
|
|
__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
|
|
|
|
|
|
|
sub stop { |
42
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
43
|
0
|
|
|
|
|
|
$self->_session->_backend->publish_stop( $self->_handle ); |
44
|
0
|
|
|
|
|
|
$self->published = 0; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub _publish_callback { |
48
|
0
|
|
|
0
|
|
|
my $self = shift; |
49
|
0
|
|
|
|
|
|
my $result = shift; |
50
|
0
|
0
|
|
|
|
|
$self->published = $result eq 'success' ? 1 : 0; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
__END__ |