00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <cabal_conn.h>
00021 #include <cabal_channel.h>
00022 #include <cabal_defs.h>
00023 #include <cabal_trans.h>
00024
00025 namespace Cabal
00026 {
00027
00028 Connection::Connection( Socket *s, Transmission *trans, Reception *recpt )
00029 {
00030 assert( (m_socket = s) != 0 && (m_trans = trans ) != 0 );
00031 assert( s->managed() );
00032
00033
00034 s->incref();
00035 m_recpt = recpt;
00036
00037 m_trans->init( this );
00038
00039 m_channel = 0;
00040 m_nextSchedule = -1;
00041 m_line = 0;
00042 }
00043
00044 Connection::~Connection()
00045 {
00046
00047 if ( m_channel ) m_channel->deschedule( this );
00048
00049 m_trans->terminate( this );
00050
00051
00052 m_socket->decref();
00053 }
00054
00055 void Connection::schedule( const long int milliseconds, Priority prio )
00056 {
00057 assert( m_socket->managed() );
00058
00059 long int msecs = 0;
00060
00061 if ( prio != realtime )
00062 {
00063 if ( m_line )
00064 msecs = m_line->minimalWait();
00065
00066 if ( milliseconds > msecs )
00067 msecs = milliseconds;
00068 }
00069 else
00070 msecs = milliseconds;
00071
00072 m_nextSchedule = Net::timeOfDay() + msecs;
00073 m_channel = m_socket->channel();
00074 m_channel->schedule( this, prio );
00075 }
00076
00077 }
00078