3 # A thing that implements dxcluster 'protocol'
5 # This is a perl module/program that sits on the end of a dxcluster
6 # 'protocol' connection and deals with anything that might come along.
8 # this program is called by ax25d and gets raw ax25 text on its input
10 # Copyright (c) 1998 Dirk Koopman G1TLH
23 @inqueue = undef; # the main input queue, an array of hashes
25 # handle out going messages
28 my ($conn, $sort, $call, $line) = @_;
30 print DEBUG "$t > $sort $call $line\n" if defined DEBUG;
31 print "> $sort $call $line\n";
32 $conn->send_now("$sort$call|$line");
37 my ($conn, $sort, $call, $line) = @_;
39 print DEBUG "$t > $sort $call $line\n" if defined DEBUG;
40 print "> $sort $call $line\n";
41 $conn->send_later("$sort$call|$line");
44 # handle disconnections
48 my ($user) = $dxconn->{user};
49 my ($conn) = $dxconn->{conn};
50 $user->close() if defined $user;
55 # handle incoming messages
58 my ($conn, $msg, $err) = @_;
59 my $dxconn = DXChannel->get_by_cnum($conn); # get the dxconnnect object for this message
61 if (defined $err && $err) {
66 my $self = bless {}, "inqueue";
67 $self->{dxconn} = $dxconn;
78 # cease running this program, close down all the connections nicely
82 foreach $dxconn (DXChannel->get_all()) {
87 # this is where the input queue is dealt with and things are dispatched off to other parts of
91 my $self = shift @inqueue;
94 my $data = $self->{data};
95 my $dxconn = $self->{dxconn};
96 my ($sort, $call, $line) = $data =~ /^(\w)(\S+)|(.*)$/;
98 # do the really sexy console interface bit! (Who is going to do the TK interface then?)
99 print DEBUG atime, " < $sort $call $line\n" if defined DEBUG;
100 print "< $sort $call $line\n";
104 if ($dxconn) { # there should not be one of these, disconnect
107 my $user = DXUser->get($call); # see if we have one of these
112 #############################################################
114 # The start of the main line of code
116 #############################################################
118 # open the debug file, set various FHs to be unbuffered
119 open(DEBUG, ">>$debugfn") or die "can't open $debugfn($!)\n";
120 select DEBUG; $| = 1;
121 select STDOUT; $| = 1;
123 # initialise User file system
124 DXUser->init($userfn);
126 # start listening for incoming messages/connects
127 Msg->new_server("$clusteraddr", $clusterport, \&login);
130 $SIG{'INT'} = \&cease;
131 $SIG{'TERM'} = \&cease;
132 $SIG{'HUP'} = 'IGNORE';
134 # this, such as it is, is the main loop!
136 Msg->event_loop(1, 0.001);