ec9f96dcf1fe2ca49a0a4e498c8c30efc776d617
[spider.git] / perl / QXProt / QXP.pm
1 #
2 # This module is part of the new protocal mode for a dx cluster
3 #
4 # This module handles ping requests
5 #
6 # Copyright (c) 2003 Dirk Koopman G1TLH
7 #
8 # $Id$
9
10
11 package QXP;
12
13 use strict;
14
15 use vars qw(@ISA $VERSION $BRANCH);
16 @ISA = qw(QXProt);
17
18 $VERSION = sprintf( "%d.%03d", q$Revision$ =~ /(\d+)\.(\d+)/ );
19 $BRANCH = sprintf( "%d.%03d", q$Revision$ =~ /\d+\.\d+\.(\d+)\.(\d+)/  || (0,0));
20 $main::build += $VERSION;
21 $main::branch += $BRANCH;
22
23 sub handle
24 {
25         my ($self, $to, $from, $msgid, $line) = @_;
26         
27         my @f = split /\^/, $line;
28
29         # is it for us?
30         if ($to eq $main::mycall) {
31                 if ($f[0] == 1) {
32                         $self->send(gen($self, $from, '0', $f[1], $f[2], $f[3]));
33                 } else {
34                         # it's a reply, look in the ping list for this one
35                         $self->handlepingreply($from);
36                 }
37         } else {
38
39                 # route down an appropriate thingy
40                 $self->route($to, $line);
41         }
42 }
43
44 sub gen
45 {
46         my ($self, $to, $flag, $user, $secs, $usecs) = @_;
47         my @out = ('P', $to, $flag);
48         push @out, $user if defined $user;
49         push @out, $secs if defined $secs;      
50         push @out, $usecs if defined $usecs;    
51         return $self->frame(@out);
52 }
53
54 1;