X-Git-Url: http://dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2FWeb.pm;h=eec12c688449f2d4c92809d795114612c36d1c9c;hb=c6a62ff483f8887b4157e111a405fef971ade8d9;hp=fbba02f652d27ebebf118c55e9da89aa4d647f0b;hpb=acf26488adcdf8852419818897405d10f895e16a;p=spider.git diff --git a/perl/Web.pm b/perl/Web.pm index fbba02f6..eec12c68 100644 --- a/perl/Web.pm +++ b/perl/Web.pm @@ -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;