line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::WAMP::Role::Publisher; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=encoding utf-8 |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Net::WAMP::Role::Publisher - Publisher role for Net::WAMP |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
package MyWAMP; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use parent qw( Net::WAMP::Role::Publisher ); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub on_PUBLISHED { ... } |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub on_ERROR_PUBLISH { ... } |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
package main; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $wamp = MyWAMP->new( on_send => sub { ... } ); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
$wamp->send_PUBLISH( {}, 'some.topic', \@args, \%args_kv ); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 DESCRIPTION |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
See the main L documentation for more background on |
28
|
|
|
|
|
|
|
how to use this class in your code. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
31
|
|
|
|
|
|
|
|
32
|
1
|
|
|
1
|
|
407
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
23
|
|
33
|
1
|
|
|
1
|
|
2
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
22
|
|
34
|
|
|
|
|
|
|
|
35
|
1
|
|
|
|
|
4
|
use parent qw( |
36
|
|
|
|
|
|
|
Net::WAMP::Role::Base::Client |
37
|
1
|
|
|
1
|
|
2
|
); |
|
1
|
|
|
|
|
1
|
|
38
|
|
|
|
|
|
|
|
39
|
1
|
|
|
1
|
|
40
|
use Module::Load (); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
10
|
|
40
|
|
|
|
|
|
|
|
41
|
1
|
|
|
1
|
|
3
|
use Types::Serialiser (); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
15
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
use constant { |
44
|
1
|
|
|
|
|
38
|
receiver_role_of_PUBLISH => 'broker', |
45
|
1
|
|
|
1
|
|
2
|
}; |
|
1
|
|
|
|
|
2
|
|
46
|
|
|
|
|
|
|
|
47
|
1
|
|
|
1
|
|
4
|
use Net::WAMP::Role::Base::Client::Features (); |
|
1
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
30
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
BEGIN { |
50
|
1
|
|
|
1
|
|
126
|
$Net::WAMP::Role::Base::Client::Features::FEATURES{'publisher'}{'features'}{'publisher_exclusion'} = $Types::Serialiser::true; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub send_PUBLISH { |
54
|
1
|
|
|
1
|
0
|
10
|
my ($self, $opts_hr, $topic, @args) = @_; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
#Considered being “nice” and allowing this, but we never know |
57
|
|
|
|
|
|
|
#when WAMP might actually try to utilize number or string values. |
58
|
|
|
|
|
|
|
#local $opts_hr->{'acknowledge'} = ${ *{$Types::Serialiser::{ $opts_hr->{'acknowledge'} ? 'true' : 'false' }}{'SCALAR'} } if exists $opts_hr->{'acknowledge'}; |
59
|
|
|
|
|
|
|
|
60
|
1
|
|
|
|
|
7
|
my $msg = $self->_create_and_send_session_msg( |
61
|
|
|
|
|
|
|
'PUBLISH', |
62
|
|
|
|
|
|
|
$opts_hr, |
63
|
|
|
|
|
|
|
$topic, |
64
|
|
|
|
|
|
|
@args, |
65
|
|
|
|
|
|
|
); |
66
|
|
|
|
|
|
|
|
67
|
1
|
50
|
|
|
|
4
|
if ($msg->publisher_wants_acknowledgement()) { |
68
|
1
|
|
|
|
|
38
|
$self->{'_sent_PUBLISH'}{$msg->get('Request')} = $msg; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
1
|
|
|
|
|
2
|
return $msg; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub _receive_PUBLISHED { |
75
|
1
|
|
|
1
|
|
3
|
my ($self, $msg) = @_; |
76
|
|
|
|
|
|
|
|
77
|
1
|
50
|
|
|
|
4
|
if (!delete $self->{'_sent_PUBLISH'}{ $msg->get('Request') }) { |
78
|
0
|
|
|
|
|
0
|
warn sprintf("Received PUBLISHED for unknown! (%s)", $msg->get('Request')); #XXX |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
1
|
|
|
|
|
65
|
return; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; |