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

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

revision 46 by knops.gerd, Mon Feb 4 19:24:25 2008 UTC revision 62 by andrew.betts, Thu Nov 27 00:33:21 2008 UTC
# Line 70  sub processLine { Line 70  sub processLine {
70          # COUNTSUBSCRIBERS channel1          # COUNTSUBSCRIBERS channel1
71          # < OK 344          # < OK 344
72                    
73          unless($line=~s/^(ADDMESSAGE|COUNTSUBSCRIBERS|LISTCHANNELS|SHOWSTATS|QUIT)//)          unless($line=~s/^(ADDMESSAGE|COUNTSUBSCRIBERS|LISTCHANNELS|LISTSUBSCRIBERS|LISTCONNECTIONS|DESCRIBE|SHOWSTATS|QUIT)//)
74          {          {
75                  $self->write("ERR Invalid command syntax$::CRLF");                  $self->write("ERR Invalid command syntax$::CRLF");
76                                    
# Line 99  sub processLine { Line 99  sub processLine {
99                  unless($line=~s/^\s+(\S+)$//)                  unless($line=~s/^\s+(\S+)$//)
100                  {                  {
101                          $self->write("ERR Invalid command syntax$::CRLF");                          $self->write("ERR Invalid command syntax$::CRLF");
                           
102                          return;                          return;
103                  }                  }
104                                    
# Line 115  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                          return;                          return;
118                  }                  }
119                                    
# Line 123  sub processLine { Line 121  sub processLine {
121                                    
122                  $self->write($txt);                  $self->write($txt);
123          }          }
124            elsif($cmd eq 'LISTSUBSCRIBERS')
125            {
126                    unless($line eq '')
127                    {
128                            $self->write("ERR Invalid command syntax$::CRLF");
129                            return;
130                    }
131                    
132                    my $txt="OK$::CRLF".Meteor::Subscriber->listSubscribers()."--EOT--$::CRLF";
133                    
134                    $self->write($txt);
135            }
136            elsif($cmd eq 'LISTCONNECTIONS')
137            {
138                    unless($line eq '')
139                    {
140                            $self->write("ERR Invalid command syntax$::CRLF");
141                            return;
142                    }
143                    
144                    my $txt="OK$::CRLF".Meteor::Connection->listConnections()."--EOT--$::CRLF";
145                    
146                    $self->write($txt);
147            }
148            elsif($cmd eq 'DESCRIBE')
149            {
150                    unless($line=~s/^\s+(\S+)$//)
151                    {
152                            $self->write("ERR Invalid command syntax$::CRLF");
153                            return;
154                    }
155                    
156                    my $filenum=$1;
157                    my $condesc=Meteor::Connection->describeConnWithFileNum($filenum);
158                    if ($condesc != -1) {
159                            $self->write("OK$::CRLF");
160                            $self->write($condesc);
161                            $self->write("--EOT--$::CRLF");
162    
163                    } else {
164                            $self->write("ERR Unknown client$::CRLF");
165                    }              
166            }
167          elsif($cmd eq 'SHOWSTATS')          elsif($cmd eq 'SHOWSTATS')
168          {          {
169                  # uptime                  # uptime
# Line 133  sub processLine { Line 174  sub processLine {
174                  my $numChannels=Meteor::Channel->numChannels();                  my $numChannels=Meteor::Channel->numChannels();
175                  $txt.="channel_count: $numChannels$::CRLF";                  $txt.="channel_count: $numChannels$::CRLF";
176                                    
177                    # connection_count
178                    my $numConnections=Meteor::Connection->connectionCount();
179                    $txt.="connection_count: $numConnections$::CRLF";
180    
181                    # subscriber count = current_subscribers + number of pollers in last minute
182                    my $now = time; my $numpoll = 0;
183                    foreach my $key (keys %{$::Pollers}) {
184                            if($::Pollers->{$key} < ($now-60) || Meteor::Subscriber->subscriberExists($key)) {
185                                    delete $::Pollers->{$key};
186                            } else {
187                                    $numpoll++;
188                            }
189                    }
190                    my $numsub = 0;
191                    if (exists($::Statistics->{'current_subscribers'})) {
192                            $numsub = $::Statistics->{'current_subscribers'};
193                    }
194                    $txt.="real_subscribers: ".($numpoll+$numsub)."$::CRLF";
195    
196                  foreach my $key (keys %{$::Statistics})                  foreach my $key (keys %{$::Statistics})
197                  {                  {
198                          $txt.=$key.': '.$::Statistics->{$key}.$::CRLF;                          $txt.=$key.': '.$::Statistics->{$key}.$::CRLF;

Legend:
Removed from v.46  
changed lines
  Added in v.62

  ViewVC Help
Powered by ViewVC 1.1.26