Add support for turning off server connections
This commit is contained in:
19
logger.pm
19
logger.pm
@@ -361,6 +361,12 @@ sub partChannel {
|
||||
$aStream->send(sprintf("PART %s\r\n", $aChannel));
|
||||
}
|
||||
|
||||
sub quitFromServer {
|
||||
my $aStream = $_[0];
|
||||
|
||||
$aStream->send("QUIT\r\n");
|
||||
}
|
||||
|
||||
sub handleNames {
|
||||
my $aCommand = $_[0];
|
||||
my $aChannels = $_[1];
|
||||
@@ -413,17 +419,22 @@ sub connectionWorker {
|
||||
|
||||
my $buffer = "";
|
||||
my @actionQueue :shared;
|
||||
my $running = 1;
|
||||
my @connection :shared = ($aServerName, \@actionQueue);
|
||||
push(@connections, \@connection);
|
||||
my %logFiles;
|
||||
while($running) {
|
||||
my $stream = connectToServer($aHost, $aPort, $aServerName);
|
||||
my $streamSelect = IO::Select->new($stream);
|
||||
while(!eof($stream)) {
|
||||
while(!eof($stream) && $running) {
|
||||
if(scalar(@actionQueue)>0) {
|
||||
given($actionQueue[0]) {
|
||||
when("JOIN") { joinChannel($stream, $actionQueue[1]); }
|
||||
when("PART") { partChannel($stream, $actionQueue[1]); }
|
||||
when("QUIT") {
|
||||
quitFromServer($stream);
|
||||
$running = 0;
|
||||
}
|
||||
}
|
||||
@actionQueue = ();
|
||||
}
|
||||
@@ -460,6 +471,12 @@ sub connectionWorker {
|
||||
}
|
||||
close($stream);
|
||||
}
|
||||
foreach my $i (0..scalar(@connections)-1) {
|
||||
if($connections[$i][0] eq $aServerName) {
|
||||
$connections[$i][0] = "";
|
||||
last;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub createLogger {
|
||||
|
||||
Reference in New Issue
Block a user