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 |
|
|
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 |
|
|
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 |
|
|
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 |
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; |