put dx.pl into an explicit handle sub
[spider.git] / perl / Web.pm
1 #
2 # DXSpider - The Web Interface Helper Routines
3 #
4 # Copyright (c) 2015 Dirk Koopman G1TLH
5 #
6
7 use strict;
8
9 package Web;
10
11 use DXDebug;
12 use DXChannel;
13 use DXLog;
14
15 require Exporter;
16 our @ISA = qw(DXCommandmode Exporter);
17 our @EXPORT = qw(is_webcall find_next_webcall);
18
19 our $maxssid = 64;                              # the maximum number of bare @WEB connections we will allow - this is really to stop runaway connections from the dxweb app
20
21 sub is_webcall
22 {
23         return $_[0] =~ /^\#WEB/;
24 }
25
26 sub find_next_webcall
27 {
28         foreach my $i (1 .. $maxssid) {
29                 next if DXChannel::get("\#WEB-$i");
30                 return "\#WEB-$i";
31         }
32         return undef;
33 }
34
35 sub new 
36 {
37         my $self = DXChannel::alloc(@_);
38         
39         return $self;
40 }
41
42 sub disconnect
43 {
44         my $self = shift;
45         my $call = $self->call;
46         
47         return if $self->{disconnecting}++;
48
49         delete $self->{senddbg};
50         
51         LogDbg('DXCommand', "Web $call disconnected");
52
53         # this done to avoid any routing or remembering of unwanted stuff
54         DXChannel::disconnect($self);
55 }
56 1;