use JSON;
use Time::HiRes qw(gettimeofday tv_interval);
+use Mojo::UserAgent;
use Mojo::IOLoop;
use Mojo::IOLoop::Subprocess;
-use Mojo::UserAgent;
+use DXSubprocess;
use strict;
use vars qw(%Cache %cmd_cache $errstr %aliases $scriptbase %nothereslug
$self->{here} = 1;
$self->{prompt} = $user->prompt if $user->prompt;
$self->{lastmsgpoll} = 0;
+ $self->{rbn} = $user->wantrbn;
+ $self->{ft} = $user->wantft;
+ $self->{cw} = $user->wantcw;
# sort out new dx spot stuff
$user->wantdxcq(0) unless defined $user->{wantdxcq};
$script->run($self) if $script;
# send cluster info
- my $info = Route::cluster();
- $self->send("Cluster:$info");
+ $self->send($self->run_cmd("show/cluster"));
# send prompts for qth, name and things
$self->send($self->msg('namee1')) if !$user->name;
if ($package && $self->can("${package}::handle")) {
no strict 'refs';
dbg("cmd: package $package") if isdbg('command');
- if (isdbg('progress')) {
- my $s = "CMD: '$cmd' by $call ip $self->{hostname}";
- }
my $t0 = [gettimeofday];
eval { @ans = &{"${package}::handle"}($self, $args) };
if ($@) {
- dbgprintring(25);
+ DXDebug::dbgprintring(25);
return (DXDebug::shortmess($@));
}
if (isdbg('progress')) {
my $msecs = _diffms($t0);
my $s = "CMD: '$cmd $args' by $call ip: $self->{hostname} ${msecs}mS";
- dbg($s);
+ dbg($s) if $cmd !~ /^(?:echo|blank)/ || isdbg('echo'); # cut down a bit on HRD and other clients' noise
}
} else {
dbg("cmd: $package not present") if isdbg('command');
return @out;
}
- my $fc = Mojo::IOLoop::Subprocess->new;
+ my $fc = DXSubprocess->new;
# $fc->serializer(\&encode_json);
# $fc->deserializer(\&decode_json);
$fc->run(
sub {
my $subpro = shift;
- if (isdbg('progress')) {
- my $s = "line: $line";
- $s .= ", args: " . join(', ', @$args) if $args && @$args;
+ if (isdbg('spawn')) {
+ my $s = __PACKAGE__ . qq{ line: "$line"};
+ $s .= ", args: " . join(', ', map { defined $_ ? qq{'$_'} : q{'undef'} } @$args) if $args && @$args;
dbg($s);
}
eval { @out = $cmdref->(@$args); };
$dxchan->send(@res);
}
}
- diffms("by $call", $line, $t0, scalar @res) if isdbg('progress');
+ diffms(__PACKAGE__, "by $call", $line, $t0, scalar @res) if isdbg('progress');
});
return @out;