Start (serious) web interface work
[spider.git] / perl / Web.pm
index fbba02f652d27ebebf118c55e9da89aa4d647f0b..eec12c688449f2d4c92809d795114612c36d1c9c 100644 (file)
@@ -1,5 +1,5 @@
 #
-# DXSpider - The Web Interface
+# DXSpider - The Web Interface Helper Routines
 #
 # Copyright (c) 2015 Dirk Koopman G1TLH
 #
@@ -8,18 +8,49 @@ use strict;
 
 package Web;
 
-use Mojolicious::Lite;
-use Mojo::IOLoop;
 use DXDebug;
+use DXChannel;
+use DXLog;
 
-sub start_node
+require Exporter;
+our @ISA = qw(DXCommandmode Exporter);
+our @EXPORT = qw(is_webcall find_next_webcall);
+
+our $maxssid = 64;                             # the maximum number of bare @WEB connections we will allow - this is really to stop runaway connections from the dxweb app
+
+sub is_webcall
 {
-       dbg("Before Web::start_node");
+       return $_[0] =~ /^\#WEB/;
+}
 
-       Mojo::IOLoop->start unless Mojo::IOLoop->is_running;
+sub find_next_webcall
+{
+       foreach my $i (1 .. $maxssid) {
+               next if DXChannel::get("\#WEB-$i");
+               return "\#WEB-$i";
+       }
+       return undef;
+}
 
-       dbg("After Web::start_node");
+sub new 
+{
+       my $self = DXChannel::alloc(@_);
+       
+       return $self;
 }
 
+sub disconnect
+{
+       my $self = shift;
+       my $call = $self->call;
+       
+       return if $self->{disconnecting}++;
+
+       delete $self->{senddbg};
+       
+       LogDbg('DXCommand', "Web $call disconnected");
 
+       # this done to avoid any routing or remembering of unwanted stuff
+       DXChannel::disconnect($self);
+}
 1;