#
-# DXSpider - The Web Interface
+# DXSpider - The Web Interface Helper Routines
#
# Copyright (c) 2015 Dirk Koopman G1TLH
#
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
+{
+ return $_[0] =~ /^\#WEB/;
+}
+
+sub find_next_webcall
{
- Mojo::IOLoop->start unless Mojo::IOLoop->is_running;
+ foreach my $i (1 .. $maxssid) {
+ next if DXChannel::get("\#WEB-$i");
+ return "\#WEB-$i";
+ }
+ return undef;
+}
- dbg("After Mojo::IOLoop");
+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;