2 # module to manage channel lists & data
4 # Copyright (c) 1998 - Dirk Koopman G1TLH
18 # create a new connection object [$obj = Connect->new($call, $msg_conn_obj, $user_obj)]
21 my ($pkg, $call, $conn, $user) = @_;
24 die "trying to create a duplicate channel for $call" if $connects{$call};
25 $self->{call} = $call;
26 $self->{conn} = $conn;
27 $self->{user} = $user;
31 return $connects{$call} = $self;
34 # obtain a connection object by callsign [$obj = Connect->get($call)]
37 my ($pkg, $call) = @_;
38 return $connect{$call};
41 # obtain all the connection objects
45 return values(%connects);
48 # obtain a connection object by searching for its connection reference
51 my ($pkg, $conn) = @_;
54 foreach $self (values(%connects)) {
55 return $self if ($self->{conn} == $conn);
60 # get rid of a connection object [$obj->del()]
64 delete $connects{$self->{call}};
68 # handle out going messages
73 my $call = $self->{call};
74 my $conn = $self->{conn};
80 print main::DEBUG "$t > $sort $call $line\n" if defined DEBUG;
81 print "> $sort $call $line\n";
82 $conn->send_now("$sort$call|$line");
90 my $call = $self->{call};
91 my $conn = $self->{conn};
97 print main::DEBUG "$t > $sort $call $line\n" if defined DEBUG;
98 print "> $sort $call $line\n";
99 $conn->send_later("$sort$call|$line");
103 # send a file (always later)
106 my ($self, $fn) = @_;
107 my $call = $self->{call};
108 my $conn = $self->{conn};
111 open(F, $fn) or die "can't open $fn for sending file ($!)";
114 $self->send_later('D', @buf);