/[Frey]/trunk/lib/Frey/Server/Continuity.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/lib/Frey/Server/Continuity.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 627 - (hide annotations)
Sat Nov 29 22:02:08 2008 UTC (15 years, 5 months ago) by dpavlin
File size: 1483 byte(s)
split out Continuity based bits to Frey::Server::Continuity
and work a bit on Frey::Mojo
1 dpavlin 627 package Frey::Server::Continuity;
2    
3     use strict;
4     use warnings;
5    
6     use Continuity;
7     #use Continuity::REPL;
8     #use Carp::REPL; ## XXX it would be nice, but it breaks error reporting too much
9    
10     #use vars qw( $repl $server );
11     #$repl = Continuity::REPL->new;
12    
13     use Frey::Server;
14     use Data::Dump qw/dump/;
15    
16     =head1 NAME
17    
18     Frey::Server - Continuity based server for Frey
19    
20     =head2 DESCRIPTION
21    
22     This is one of pissible server implementations for Frey. In it's current stage, it's also most complete one.
23    
24     =head2 run
25    
26     $o->run( $optional_port );
27    
28     =cut
29    
30     our $server;
31     our $continuity;
32    
33     sub run {
34     my ( $self ) = @_;
35    
36     $server = new Frey::Server->new;
37    
38     $continuity = Continuity->new(
39     port => $server->port,
40     path_session => 1,
41     cookie_session => 'sid',
42     callback => \&callback,
43     debug_level => 2,
44     staticp => sub {
45     $_[0]->url =~ m{^/+(static|var).*\.(jpg|jpeg|gif|png|css|ico|js|html?|xml|json|ya?ml)(\?.*)?$}
46     },
47     );
48     $Module::Reload::Debug = 1; # auto if debug_level > 1
49     Frey::ClassLoader->new->load_all_classes();
50     Frey::Editor->new->switch_screen if $ENV{FREY_SWITCH_SCREEN};
51     $continuity->loop;
52     }
53    
54     sub callback {
55     my ($req) = @_;
56    
57     # $req->send_headers("X-Frey-VERSION: $Frey::VERSION");
58    
59     $server->{print} = sub {
60     $req->print( @_ );
61     };
62    
63     warn dump( $req->params );
64    
65     my %p = $req->params;
66     warn "# params: ",dump( %p );
67    
68     $server->request( $req->request->url, \%p );
69    
70     if ( $req->conn ) {
71     $req->print( "\r\n" ); # flush
72     $req->conn->close;
73     warn "## close connection: $@";
74     }
75     }
76    
77    
78     1;

  ViewVC Help
Powered by ViewVC 1.1.26