| 1 | package POE::Component::Server::Bayeux::Message::Factory; | ||||||||||||||||||
| 2 | |||||||||||||||||||
| 3 | =head1 NAME | ||||||||||||||||||
| 4 | |||||||||||||||||||
| 5 | POE::Component::Server::Bayeux::Message::Factory - create messages in the right subclass | ||||||||||||||||||
| 6 | |||||||||||||||||||
| 7 | =head1 DESCRIPTION | ||||||||||||||||||
| 8 | |||||||||||||||||||
| 9 | Implements create(), which will find the appropriate Message subclass to handle the data packet. | ||||||||||||||||||
| 10 | |||||||||||||||||||
| 11 | =cut | ||||||||||||||||||
| 12 | |||||||||||||||||||
| 13 | 3 | ▶ | use strict; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 14 | 3 | ▶ | use warnings; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 15 | 3 | ▶ | use POE qw( | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 16 | Component::Server::Bayeux::Message::Invalid | ||||||||||||||||||
| 17 | Component::Server::Bayeux::Message::Meta | ||||||||||||||||||
| 18 | Component::Server::Bayeux::Message::Service | ||||||||||||||||||
| 19 | Component::Server::Bayeux::Message::Publish | ||||||||||||||||||
| 20 | 3 | ); | |||||||||||||||||
| 21 | |||||||||||||||||||
| 22 | 3 | ▶ | use Params::Validate qw(validate HASHREF ARRAYREF); | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 23 | |||||||||||||||||||
| 24 | 0 | ▶ | sub create { | ||||||||||||||||
|
Subroutine
create: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||
| 25 | 0 | my $class = shift; | |||||||||||||||||
| 26 | |||||||||||||||||||
| 27 | 0 | my %args = validate(@_, { | |||||||||||||||||
| 28 | request => 1, | ||||||||||||||||||
| 29 | data => { type => HASHREF }, | ||||||||||||||||||
| 30 | }); | ||||||||||||||||||
| 31 | |||||||||||||||||||
| 32 | 0 | my $channel = $args{data}{channel}; | |||||||||||||||||
| 33 | |||||||||||||||||||
| 34 | 0 | my $build_class; | |||||||||||||||||
| 35 | 0 | ▶ | if (! $channel) { | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 36 | 0 | $build_class = 'Invalid'; | |||||||||||||||||
| 37 | } | ||||||||||||||||||
| 38 | elsif ($channel =~ m{^/meta/}) { | ||||||||||||||||||
| 39 | 0 | $build_class = 'Meta'; | |||||||||||||||||
| 40 | } | ||||||||||||||||||
| 41 | elsif ($channel =~ m{^/service/}) { | ||||||||||||||||||
| 42 | 0 | $build_class = 'Service'; | |||||||||||||||||
| 43 | } | ||||||||||||||||||
| 44 | else { | ||||||||||||||||||
| 45 | 0 | $build_class = 'Publish'; | |||||||||||||||||
| 46 | } | ||||||||||||||||||
| 47 | |||||||||||||||||||
| 48 | 0 | $build_class = 'POE::Component::Server::Bayeux::Message::' . $build_class; | |||||||||||||||||
| 49 | 0 | return $build_class->new(%args); | |||||||||||||||||
| 50 | } | ||||||||||||||||||
| 51 | |||||||||||||||||||
| 52 | =head1 COPYRIGHT | ||||||||||||||||||
| 53 | |||||||||||||||||||
| 54 | Copyright (c) 2008 Eric Waters and XMission LLC (http://www.xmission.com/). | ||||||||||||||||||
| 55 | All rights reserved. This program is free software; you can redistribute it | ||||||||||||||||||
| 56 | and/or modify it under the same terms as Perl itself. | ||||||||||||||||||
| 57 | |||||||||||||||||||
| 58 | The full text of the license can be found in the LICENSE file included with | ||||||||||||||||||
| 59 | this module. | ||||||||||||||||||
| 60 | |||||||||||||||||||
| 61 | =head1 AUTHOR | ||||||||||||||||||
| 62 | |||||||||||||||||||
| 63 | Eric Waters <ewaters@uarc.com> | ||||||||||||||||||
| 64 | |||||||||||||||||||
| 65 | =cut | ||||||||||||||||||
| 66 | |||||||||||||||||||
| 67 | 3 | 1; | |||||||||||||||||