use Route;
use Route::User;
use DXUtil;
+use DXJSON;
+use Time::HiRes qw(gettimeofday);
use strict;
%list = ();
$max = 0;
$obscount = 3;
+our $cachefn = localdata('route_node_cache');
sub count
{
return @out;
}
+# is a user on this node
+sub is_user
+{
+ my $self = shift;
+ my $call = shift;
+ return scalar grep {$_ eq $call} @{$self->{users}};
+}
+
sub usercount
{
my $self = shift;
return (%{$parent->{PC92C_dxchan}});
}
+sub TO_JSON { return { %{ shift() } }; }
+
+sub write_cache
+{
+ my $json = DXJSON->new;
+ $json->canonical(isdbg('routecache'));
+
+ my $ta = [ gettimeofday ];
+ my @s;
+ eval {
+ while (my ($k, $v) = each %list) {
+ push @s, "$k:" . $json->encode($v) . "\n";
+ }
+ };
+ if (!$@ && @s) {
+ my $fh = IO::File->new(">$cachefn") or confess("writing $cachefn $!");
+ if (isdbg("routecache")) {
+ $fh->print(sort @s);
+ }
+ else {
+ $fh->print(@s);
+ }
+ $fh->close;
+ } else {
+ dbg("Route::Node:Write_cache error '$@'");
+ return;
+ }
+ $json->indent(0)->canonical(0);
+ my $diff = _diffms($ta);
+ dbg("Route::Node:WRITE_CACHE time to write: $diff mS");
+}
+
+
sub DESTROY
{
my $self = shift;