Changeset 8679 for lang/perl/Punc/branches
- Timestamp:
- 04/02/08 23:29:42 (8 months ago)
- Location:
- lang/perl/Punc/branches/ssl
- Files:
-
- 5 added
- 3 modified
-
bin/punc (modified) (1 diff)
-
bin/puncd (modified) (1 diff)
-
bin/puncmasterd (added)
-
etc (added)
-
lib/Punc/Daemon.pm (added)
-
lib/Punc/Master (added)
-
lib/Punc/Master/Daemon.pm (added)
-
lib/Punc/Slave/Daemon.pm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/Punc/branches/ssl/bin/punc
r8644 r8679 3 3 use strict; 4 4 use warnings; 5 use FindBin; 6 use File::Spec; 7 use lib File::Spec->catdir("$FindBin::Bin/..", 'lib'); 5 8 use Punc::Client; 6 9 use JSON; -
lang/perl/Punc/branches/ssl/bin/puncd
r8644 r8679 3 3 use strict; 4 4 use warnings; 5 use FindBin; 6 use File::Spec; 7 use lib File::Spec->catdir("$FindBin::Bin/..", 'lib'); 8 use Punc::Slave::Daemon; 9 use Getopt::Long; 5 10 6 use Punc::Slave::Daemon;11 my $port = 7080; 7 12 8 Punc::Slave::Daemon->start_daemon; 13 GetOptions( 14 '--port=s' => $port, 15 ); 9 16 17 my $daemon = Punc::Slave::Daemon->new({ port => $port }); 18 $daemon->run; 19 20 21 -
lang/perl/Punc/branches/ssl/lib/Punc/Slave/Daemon.pm
r8644 r8679 4 4 use warnings; 5 5 6 use HTTP::Daemon; 7 use HTTP::Status; 8 use JSON; 9 use UNIVERSAL::require; 6 use base qw( Punc::Daemon ); 10 7 11 sub start_daemon { 12 my $d = HTTP::Daemon->new( LocalPort => 7080, ReuseAddr => 1 ) || die; 13 14 print "Please contact me at: <URL:", $d->url, ">\n"; 15 while ( my $c = $d->accept ) { 16 while ( my $r = $c->get_request ) { 17 my $module = $r->url->path; 18 $module =~ s!^/!!; 19 my $content = JSON::from_json($r->content); 20 my $result = dispatch_request($module, $content->{method}, $content->{params}); 21 22 my $json = to_json({ 23 result => $result, 24 error => undef, 25 }); 26 27 my $response = HTTP::Response->new; 28 $response->content($json); 29 $c->send_response($response); 30 } 31 $c->close; 32 undef($c); 33 } 34 } 35 36 sub dispatch_request { 37 my ( $module, $method, $args ) = @_; 8 sub handle_request { 9 my ( $self, $module, $method, $args ) = @_; 38 10 39 11 $module = ucfirst $module;
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)