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

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

revision 13 by knops.gerd, Mon Apr 30 18:16:17 2007 UTC revision 25 by knops.gerd, Sun May 20 19:40:53 2007 UTC
# Line 43  package Meteor::Subscriber; Line 43  package Meteor::Subscriber;
43          @Meteor::Subscriber::ISA=qw(Meteor::Connection);          @Meteor::Subscriber::ISA=qw(Meteor::Connection);
44                    
45          our %PersistentConnections=();          our %PersistentConnections=();
46            our $NumAcceptedConnections=0;
47    
48  ###############################################################################  ###############################################################################
49  # Factory methods  # Factory methods
# Line 63  sub newFromServer { Line 64  sub newFromServer {
64                  $self->{'ConnectionTimeLimit'}=$self->{'ConnectionStart'}+$maxTime;                  $self->{'ConnectionTimeLimit'}=$self->{'ConnectionStart'}+$maxTime;
65          }          }
66                    
67            $::Statistics->{'current_subscribers'}++;
68            $::Statistics->{'subscriber_connections_accepted'}++;
69            
70          $self;          $self;
71  }  }
72    
# Line 97  sub checkPersistentConnectionsForMaxTime Line 101  sub checkPersistentConnectionsForMaxTime
101          map { $_->checkForMaxTime($time) } @cons;          map { $_->checkForMaxTime($time) } @cons;
102  }  }
103    
104    sub numSubscribers {
105            
106            return scalar(keys %PersistentConnections);
107    }
108    
109  ###############################################################################  ###############################################################################
110  # Instance methods  # Instance methods
111  ###############################################################################  ###############################################################################
# Line 132  sub processLine { Line 141  sub processLine {
141                          my $startIndex=undef;                          my $startIndex=undef;
142                          my $backtrack=undef;                          my $backtrack=undef;
143                          my $persist=1;                          my $persist=1;
                         my $anyPersist=0;  
144                          my $subscriberID=undef;                          my $subscriberID=undef;
145                          my $channels={};                          my $channels={};
146                          foreach my $formElement (@formData)                          foreach my $formElement (@formData)
# Line 151  sub processLine { Line 159  sub processLine {
159                                                                                                    
160                                                  $startIndex=-$backtrack if(!defined($startIndex) && defined($backtrack));                                                  $startIndex=-$backtrack if(!defined($startIndex) && defined($backtrack));
161                                                  $channels->{$channelName}->{'startIndex'}=$startIndex;                                                  $channels->{$channelName}->{'startIndex'}=$startIndex;
                                                 $channels->{$channelName}->{'persist'}=$persist;  
                                                 $anyPersist|=$persist;  
162                                                                                                    
163                                                  $startIndex=undef;                                                  $startIndex=undef;
164                                                  $backtrack=undef;                                                  $backtrack=undef;
                                                 $persist=1;  
165                                          }                                          }
166                                          $channelName=$1;                                          $channelName=$1;
167                                  }                                  }
# Line 210  sub processLine { Line 215  sub processLine {
215                                                                    
216                                  $startIndex=-$backtrack if(!defined($startIndex) && defined($backtrack));                                  $startIndex=-$backtrack if(!defined($startIndex) && defined($backtrack));
217                                  $channels->{$channelName}->{'startIndex'}=$startIndex;                                  $channels->{$channelName}->{'startIndex'}=$startIndex;
                                 $channels->{$channelName}->{'persist'}=$persist;  
                                 $anyPersist|=$persist;  
218                          }                          }
219                                                    
220                          delete($self->{'headerBuffer'});                          delete($self->{'headerBuffer'});
221                                                    
222                          if(defined($subscriberID) && $anyPersist)                          if(defined($subscriberID) && $persist)
223                          {                          {
224                                  $self->{'subscriberID'}=$subscriberID;                                  $self->{'subscriberID'}=$subscriberID;
225                                  $self->deleteSubscriberWithID($subscriberID);                                  $self->deleteSubscriberWithID($subscriberID);
# Line 227  sub processLine { Line 230  sub processLine {
230                          {                          {
231                                  $self->emitOKHeader();                                  $self->emitOKHeader();
232                                                                    
233                                  $self->setChannels($channels);                                  $self->setChannels($channels,$persist);
234                                                                    
235                                  $self->close(1) unless($anyPersist);                                  $self->close(1) unless($persist);
236                                                                    
237                                  return;                                  return;
238                          }                          }
# Line 253  sub processLine { Line 256  sub processLine {
256  sub setChannels {  sub setChannels {
257          my $self=shift;          my $self=shift;
258          my $channels=shift;          my $channels=shift;
259            my $persist=shift;
260                    
261          foreach my $channelName (keys %{$channels})          foreach my $channelName (keys %{$channels})
262          {          {
                 my $persist=$channels->{$channelName}->{'persist'};  
263                  my $startIndex=$channels->{$channelName}->{'startIndex'};                  my $startIndex=$channels->{$channelName}->{'startIndex'};
264                                    
265                  my $channel=Meteor::Channel->channelWithName($channelName);                  my $channel=Meteor::Channel->channelWithName($channelName);
# Line 277  sub emitErrorHeader { Line 280  sub emitErrorHeader {
280          my $self=shift;          my $self=shift;
281                    
282          $self->emitHeader('404 Not Found');          $self->emitHeader('404 Not Found');
283            $::Statistics->{'errors_served'}++;
284                    
285          # close up shop here!          # close up shop here!
286          $self->close();          $self->close();
# Line 324  sub emitHeader { Line 328  sub emitHeader {
328  sub sendMessage {  sub sendMessage {
329          my $self=shift;          my $self=shift;
330          my $msg=shift;          my $msg=shift;
331            my $numMsgInThisBatch=shift;
332            
333            $numMsgInThisBatch=1 unless(defined($numMsgInThisBatch));
334                    
335          $self->write($msg);          $self->write($msg);
336                    
337            $::Statistics->{'messages_served'}+=$numMsgInThisBatch;
338            
339          my $msgCount=++$self->{'MessageCount'};          my $msgCount=++$self->{'MessageCount'};
340                    
341          my $maxMsg=$::CONF{'MaxMessages'};          my $maxMsg=$::CONF{'MaxMessages'};
# Line 384  sub close { Line 393  sub close {
393                  }                  }
394          }          }
395                    
396            $::Statistics->{'current_subscribers'}--;
397            
398          $self->SUPER::close();          $self->SUPER::close();
399  }  }
400    

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

  ViewVC Help
Powered by ViewVC 1.1.26