projects
/
spider.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add cty-1606 data.
[spider.git]
/
perl
/
DXXml.pm
diff --git
a/perl/DXXml.pm
b/perl/DXXml.pm
index 00fccde4cddd5f17f0668e55fe935ab6569a1104..b990410127167ac19f8339126fb215be371888df 100644
(file)
--- a/
perl/DXXml.pm
+++ b/
perl/DXXml.pm
@@
-18,6
+18,8
@@
use DXUtil;
use DXXml::Ping;
use DXXml::Dx;
use DXXml::IM;
use DXXml::Ping;
use DXXml::Dx;
use DXXml::IM;
+use DXXml::Text;
+use DXXml::Cmd;
use vars qw($VERSION $BRANCH $xs $id $max_old_age $max_future_age $dupeage);
$VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ );
use vars qw($VERSION $BRANCH $xs $id $max_old_age $max_future_age $dupeage);
$VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ );
@@
-37,7
+39,13
@@
sub new
{
my $pkg = shift;
my $class = ref $pkg || $pkg;
{
my $pkg = shift;
my $class = ref $pkg || $pkg;
- return bless{@_}, $class;
+ my $self = bless{}, $class;
+ while (@_) {
+ my $key = shift;
+ my $val = shift;
+ $self->{$key} = $val if defined $val;
+ }
+ return $self;
}
#
}
#
@@
-56,7
+64,7
@@
sub init
$XML::Simple::PREFERRED_PARSER = 'XML::Parser';
import XML::Simple;
$DXProt::handle_xml = 1;
$XML::Simple::PREFERRED_PARSER = 'XML::Parser';
import XML::Simple;
$DXProt::handle_xml = 1;
- $xs = new XML::Simple(C
ache=>[]
);
+ $xs = new XML::Simple(C
ontentKey=>'content', ForceArray=>1
);
}
undef $@;
}
}
undef $@;
}
@@
-99,11
+107,11
@@
sub normal
dbg("Invalid, non-existant or zero time") if isdbg('chanerr');
return;
}
dbg("Invalid, non-existant or zero time") if isdbg('chanerr');
return;
}
- unless ($t
< $main::systime - $max_old_age || $t >
$main::systime + $max_future_age) {
+ unless ($t
> $main::systime - $max_old_age && $t <
$main::systime + $max_future_age) {
dbg("Too old or too far in the future") if isdbg('chanerr');
return;
}
dbg("Too old or too far in the future") if isdbg('chanerr');
return;
}
- unless (exists $xref->{id} && ($id = $xref->{id}) >= 0 && $id <= 999
9
) {
+ unless (exists $xref->{id} && ($id = $xref->{id}) >= 0 && $id <= 999) {
dbg("Invalid or non-existant id") if isdbg('chanerr');
return;
}
dbg("Invalid or non-existant id") if isdbg('chanerr');
return;
}
@@
-117,9
+125,9
@@
sub normal
$xref->{'-timet'} = $t;
return if DXDupe::check("xml,$o,$t,$id", $dupeage);
$xref->{'-timet'} = $t;
return if DXDupe::check("xml,$o,$t,$id", $dupeage);
-
$xref
= bless $xref, $pkg;
- $
xref
->{'-xml'} = $line;
- $
xref
->handle_input($dxchan);
+
my $r
= bless $xref, $pkg;
+ $
r
->{'-xml'} = $line;
+ $
r
->handle_input($dxchan);
}
#
}
#
@@
-148,7
+156,6
@@
sub process
DXXml::Ping::add($main::me, $dxchan->call);
$dxchan->{nopings} -= 1;
$dxchan->{lastping} = $t;
DXXml::Ping::add($main::me, $dxchan->call);
$dxchan->{nopings} -= 1;
$dxchan->{lastping} = $t;
- $dxchan->{lastping} += $dxchan->{pingint} / 2 unless @{$dxchan->{pingtime}};
}
}
}
}
}
}
@@
-190,7
+197,7
@@
sub toxml
unless (exists $self->{'-xml'}) {
$self->{o} ||= $main::mycall;
unless (exists $self->{'-xml'}) {
$self->{o} ||= $main::mycall;
- $self->{t} ||= IsoTime::
day
minsec();
+ $self->{t} ||= IsoTime::
hour
minsec();
$self->{id} ||= nextid();
my ($name) = (ref $self) =~ /::(\w+)$/;
$self->{id} ||= nextid();
my ($name) = (ref $self) =~ /::(\w+)$/;
@@
-204,7
+211,13
@@
sub route
my $self = shift;
my $fromdxchan = shift;
my $to = shift;
my $self = shift;
my $fromdxchan = shift;
my $to = shift;
- my $via = $to || $self->{'-via'} || $self->{to};
+ my $via = $to;
+ my $dxchan;
+
+ if (my $u = $self->{u}) {
+ $via ||= $u if ($dxchan = DXChannel::get($u));
+ }
+ $via ||= $self->{'-via'} || $self->{to};
unless ($via) {
dbg("XML: no route specified (" . $self->toxml . ")") if isdbg('chanerr');
unless ($via) {
dbg("XML: no route specified (" . $self->toxml . ")") if isdbg('chanerr');
@@
-216,7
+229,7
@@
sub route
}
# always send it down the local interface if available
}
# always send it down the local interface if available
-
my $dxchan
= DXChannel::get($via);
+
$dxchan ||
= DXChannel::get($via);
if ($dxchan) {
dbg("route: $via -> $dxchan->{call} direct" ) if isdbg('route');
} else {
if ($dxchan) {
dbg("route: $via -> $dxchan->{call} direct" ) if isdbg('route');
} else {
@@
-249,13
+262,18
@@
sub route
return;
}
return;
}
+ $self->{o} ||= $main::mycall;
+ $self->{id} ||= nextid();
+ $self->{'-timet'} ||= $main::systime;
+
if ($dxchan->handle_xml) {
$dxchan->send($self->toxml);
if ($dxchan->handle_xml) {
$dxchan->send($self->toxml);
+ } elsif ($dxchan->is_node) {
+ my $ref = $self->topcxx($dxchan);
+ $dxchan->send($ref);
} else {
} else {
- $self->{o} ||= $main::mycall;
- $self->{id} ||= nextid();
- $self->{'-timet'} ||= $main::systime;
- $dxchan->send($self->topcxx);
+ my $ref = $self->tocmd($dxchan);
+ $dxchan->send($ref);
}
}
}
}