#
package DXChannel;
-require Exporter;
-@ISA = qw(DXCommandmode DXProt Exporter);
-
use Msg;
use DXUtil;
use DXM;
%channels = undef;
+%valid = (
+ call => 'Callsign',
+ conn => 'Msg Connection ref',
+ user => 'DXUser ref',
+ t => 'Time',
+ priv => 'Privilege',
+ state => 'Current State',
+ oldstate => 'Last State',
+ list => 'Dependant DXChannels list',
+ name => 'User Name',
+);
+
+
# create a new connection object [$obj = DXChannel->new($call, $msg_conn_obj, $user_obj)]
sub new
{
$self->{user} = $user if defined $user;
$self->{t} = time;
$self->{state} = 0;
+ $self->{oldstate} = 0;
bless $self, $pkg;
return $channels{$call} = $self;
}
foreach $line (@_) {
my $t = atime;
chomp $line;
- print main::DEBUG "$t > $sort $call $line\n" if defined DEBUG;
- print "> $sort $call $line\n";
+ print main::DEBUG "$t -> $sort $call $line\n" if defined DEBUG;
+ print "-> $sort $call $line\n";
$conn->send_now("$sort$call|$line");
}
}
foreach $line (@_) {
my $t = atime;
chomp $line;
- print main::DEBUG "$t > D $call $line\n" if defined DEBUG;
- print "> D $call $line\n";
+ print main::DEBUG "$t -> D $call $line\n" if defined DEBUG;
+ print "-> D $call $line\n";
$conn->send_later("D$call|$line");
}
}
$self->send(DXM::msg(@_));
}
+# change the state of the channel - lots of scope for debugging here :-)
+sub state
+{
+ my $self = shift;
+ $self->{oldstate} = $self->{state};
+ $self->{state} = shift;
+ print "Db $self->{call} channel state $self->{oldstate} -> $self->{state}\n" if $main::debug;
+}
+
+# various access routines
+sub AUTOLOAD
+{
+ my $self = shift;
+ my $name = $AUTOLOAD;
+
+ return if $name =~ /::DESTROY$/;
+ $name =~ s/.*:://o;
+
+ die "Non-existant field '$AUTOLOAD'" if !$valid{$name};
+ @_ ? $self->{$name} = shift : $self->{$name} ;
+}
+
1;
__END__;