/[meteor]/googlecode.com/svn/trunk/Meteor/Controller.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 /googlecode.com/svn/trunk/Meteor/Controller.pm

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

revision 24 by knops.gerd, Thu Dec 14 16:29:42 2006 UTC revision 25 by knops.gerd, Sun May 20 19:40:53 2007 UTC
# Line 38  package Meteor::Controller; Line 38  package Meteor::Controller;
38                    
39          use Meteor::Connection;          use Meteor::Connection;
40          use Meteor::Channel;          use Meteor::Channel;
41            use Meteor::Subscriber;
42                    
43          @Meteor::Controller::ISA=qw(Meteor::Connection);          @Meteor::Controller::ISA=qw(Meteor::Connection);
44    
45  ###############################################################################  ###############################################################################
46    # Factory methods
47    ###############################################################################
48    sub newFromServer {
49            my $class=shift;
50            
51            my $self=$class->SUPER::newFromServer(shift);
52            
53            $::Statistics->{'current_controllers'}++;
54            $::Statistics->{'controller_connections_accepted'}++;
55            
56            $self;
57    }
58    
59    ###############################################################################
60  # Instance methods  # Instance methods
61  ###############################################################################  ###############################################################################
62  sub processLine {  sub processLine {
# Line 55  sub processLine { Line 70  sub processLine {
70          # COUNTSUBSCRIBERS channel1          # COUNTSUBSCRIBERS channel1
71          # < OK 344          # < OK 344
72                    
73          unless($line=~s/^(ADDMESSAGE|COUNTSUBSCRIBERS|LISTCHANNELS|QUIT)//)          unless($line=~s/^(ADDMESSAGE|COUNTSUBSCRIBERS|LISTCHANNELS|SHOWSTATS|QUIT)//)
74          {          {
75                  $self->write("ERR Invalid command syntax$::CRLF");                  $self->write("ERR Invalid command syntax$::CRLF");
76                                    
# Line 69  sub processLine { Line 84  sub processLine {
84                  unless($line=~s/^\s+(\S+)\s//)                  unless($line=~s/^\s+(\S+)\s//)
85                  {                  {
86                          $self->write("ERR Invalid command syntax$::CRLF");                          $self->write("ERR Invalid command syntax$::CRLF");
87                            
88                          return;                          return;
89                  }                  }
90                                    
# Line 83  sub processLine { Line 98  sub processLine {
98                  unless($line=~s/^\s+(\S+)$//)                  unless($line=~s/^\s+(\S+)$//)
99                  {                  {
100                          $self->write("ERR Invalid command syntax$::CRLF");                          $self->write("ERR Invalid command syntax$::CRLF");
101                            
102                          return;                          return;
103                  }                  }
104                                    
# Line 99  sub processLine { Line 114  sub processLine {
114                  unless($line eq '')                  unless($line eq '')
115                  {                  {
116                          $self->write("ERR Invalid command syntax$::CRLF");                          $self->write("ERR Invalid command syntax$::CRLF");
117                            
118                          return;                          return;
119                  }                  }
120                                    
# Line 107  sub processLine { Line 122  sub processLine {
122                                    
123                  $self->write($txt);                  $self->write($txt);
124          }          }
125            elsif($cmd eq 'SHOWSTATS')
126            {
127                    # uptime
128                    my $uptime=time-$::STARTUP_TIME;
129                    my $txt="uptime: $uptime$::CRLF";
130                    
131                    # channel_count
132                    my $numChannels=Meteor::Channel->numChannels();
133                    $txt.="channel_count: $numChannels$::CRLF";
134                    
135                    foreach my $key (keys %{$::Statistics})
136                    {
137                            $txt.=$key.': '.$::Statistics->{$key}.$::CRLF;
138                    }
139                    
140                    $self->write($txt);
141            }
142          elsif($cmd eq 'QUIT')          elsif($cmd eq 'QUIT')
143          {          {
144                  unless($line eq '')                  unless($line eq '')
145                  {                  {
146                          $self->write("ERR Invalid command syntax$::CRLF");                          $self->write("ERR Invalid command syntax$::CRLF");
147                            
148                          return;                          return;
149                  }                  }
150                                    
# Line 139  sub close { Line 171  sub close {
171                  }                  }
172          }          }
173                    
174            $::Statistics->{'current_controllers'}--;
175            
176          $self->SUPER::close();          $self->SUPER::close();
177  }  }
178    

Legend:
Removed from v.24  
changed lines
  Added in v.25

  ViewVC Help
Powered by ViewVC 1.1.26