/[Frey]/trunk/lib/Frey/Server.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

Diff of /trunk/lib/Frey/Server.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 30 by dpavlin, Sun Jun 29 20:48:35 2008 UTC revision 38 by dpavlin, Mon Jun 30 20:02:08 2008 UTC
# Line 4  use strict; Line 4  use strict;
4  use warnings;  use warnings;
5    
6  use Continuity;  use Continuity;
7  use Continuity::REPL;  #use Continuity::REPL;
8  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
9    
10  use base 'Frey';  use base 'Frey';
# Line 15  my $got_message; # Flag to indicate that Line 15  my $got_message; # Flag to indicate that
15    
16  use vars qw( $repl $server );  use vars qw( $repl $server );
17    
18  sub run {  #$repl = Continuity::REPL->new;
19          $repl = Continuity::REPL->new;  $server = Continuity->new(
20          $server = Continuity->new(          port => 16001,
21            port => 16001,          path_session => 1,
22            path_session => 1,          cookie_session => 'sid',
23            cookie_session => 'sid',          callback => \&main,
24            callback => \&main,          debug_level => 3,
25          );  );
         $server->debug_level( 2 );  
26    
27    sub run {
28          $server->loop;          $server->loop;
29  }  }
30    
# Line 32  sub run { Line 32  sub run {
32  # pushstream, a sent message, or a request for the main HTML. We delegate each  # pushstream, a sent message, or a request for the main HTML. We delegate each
33  # of these cases, none of which will return (they all loop forever).  # of these cases, none of which will return (they all loop forever).
34  sub main {  sub main {
35    my ($req) = @_;          my ($req) = @_;
36        
37    my $path = $req->request->url->path;          my $path = $req->request->url->path;
38    warn "REQUEST: $path\n";          warn "REQUEST: $path\n";
39    
40          warn $req->request->header('User_Agent');          warn $req->request->header('User_Agent');
41  #warn dump( $req );  #warn dump( $req );
42    
43    # If this is a request for the pushtream, then give them that          # If this is a request for the pushtream, then give them that
44    if($path =~ /pushstream/) {          if($path =~ /pushstream/) {
45          pushstream($req);                  pushstream($req);
46    }          }
47        
48    # If they are sending us a message, we give them a thread for that too          # If they are sending us a message, we give them a thread for that too
49    if($path =~ /sendmessage/) {          if($path =~ /sendmessage/) {
50          send_message($req);                  send_message($req);
51    }          }
52    
53    # Otherwise, lets give them page          # Otherwise, lets give them page
54    send_page($req);          send_page($req);
55  }  }
56    
57  # Here we accept a connection to the browser, and keep it open. Meanwhile we  # Here we accept a connection to the browser, and keep it open. Meanwhile we

Legend:
Removed from v.30  
changed lines
  Added in v.38

  ViewVC Help
Powered by ViewVC 1.1.26