| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package POE::Component::Server::Bayeux::Message::Publish; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
POE::Component::Server::Bayeux::Message::Publish - handles non-special channels |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Subclasses L to implement the non-special channels. This will usually mean a publish to a channel, so a successfuly handled message will simply be passed to the server via $request->publish(), with a response given back to the requesting client. |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=cut |
|
12
|
|
|
|
|
|
|
|
|
13
|
3
|
|
|
3
|
|
2024
|
use strict; |
|
|
3
|
|
|
|
|
10
|
|
|
|
3
|
|
|
|
|
101
|
|
|
14
|
3
|
|
|
3
|
|
17
|
use warnings; |
|
|
3
|
|
|
|
|
20
|
|
|
|
3
|
|
|
|
|
79
|
|
|
15
|
3
|
|
|
3
|
|
17
|
use JSON::Any qw(XS); |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
29
|
|
|
16
|
3
|
|
|
3
|
|
483
|
use base qw(POE::Component::Server::Bayeux::Message); |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
1271
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
__PACKAGE__->mk_data_accessors(qw(data)); |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub validate_fields { |
|
21
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
|
22
|
|
|
|
|
|
|
|
|
23
|
0
|
0
|
|
|
|
|
$self->SUPER::validate_fields( |
|
24
|
|
|
|
|
|
|
data => 1, |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# Optional to require clientId on publish |
|
27
|
|
|
|
|
|
|
($self->server_config->{AnonPublish} ? |
|
28
|
|
|
|
|
|
|
() : ( |
|
29
|
|
|
|
|
|
|
clientId => 1, |
|
30
|
|
|
|
|
|
|
)), |
|
31
|
|
|
|
|
|
|
); |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub handle { |
|
35
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Class handle() will call validate_fields() |
|
38
|
0
|
|
|
|
|
|
$self->SUPER::handle(); |
|
39
|
0
|
0
|
|
|
|
|
return $self->handle_error() if $self->is_error(); |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# Perform client acl (if client provided) |
|
42
|
0
|
|
|
|
|
|
my $client; |
|
43
|
0
|
0
|
|
|
|
|
if ($self->clientId) { |
|
44
|
0
|
|
|
|
|
|
$client = $self->request->client($self->clientId); |
|
45
|
0
|
|
|
|
|
|
$client->message_acl($self); |
|
46
|
0
|
0
|
|
|
|
|
return $self->handle_error() if $self->is_error(); |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
$self->request->publish($self->clientId, $self->channel, $self->data); |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# Optional to respond to a publish |
|
52
|
0
|
|
|
|
|
|
$self->add_response({ |
|
53
|
|
|
|
|
|
|
successful => JSON::XS::true, |
|
54
|
|
|
|
|
|
|
}); |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub handle_error { |
|
58
|
0
|
|
|
0
|
0
|
|
my ($self, $error) = @_; |
|
59
|
|
|
|
|
|
|
|
|
60
|
0
|
|
0
|
|
|
|
my %response = ( |
|
61
|
|
|
|
|
|
|
successful => JSON::XS::false, |
|
62
|
|
|
|
|
|
|
error => $error || $self->is_error || '', |
|
63
|
|
|
|
|
|
|
); |
|
64
|
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
return $self->add_response(\%response); |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub add_response { |
|
69
|
0
|
|
|
0
|
0
|
|
my ($self, $response) = @_; |
|
70
|
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
foreach my $key (qw(channel clientId id)) { |
|
72
|
0
|
0
|
|
|
|
|
$response->{$key} = $self->$key if defined $self->$key; |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
$self->request->add_response($response); |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Copyright (c) 2008 Eric Waters and XMission LLC (http://www.xmission.com/). |
|
81
|
|
|
|
|
|
|
All rights reserved. This program is free software; you can redistribute it |
|
82
|
|
|
|
|
|
|
and/or modify it under the same terms as Perl itself. |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
The full text of the license can be found in the LICENSE file included with |
|
85
|
|
|
|
|
|
|
this module. |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 AUTHOR |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Eric Waters |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |