Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

cabal_conn.cpp

00001 /*
00002    Cabal - cabal_conn.cpp
00003    Short description
00004 
00005    $Id: cabal_conn.cpp,v 1.4 2004/04/05 21:54:18 jonnymind Exp $
00006 ---------------------------------------------
00007    Begin      : ven mar 26 2004 02:13
00008    Author     : Giancarlo Niccolai <gc@niccolai.ws>, (C) 2004
00009 
00010    Last modified because:
00011 
00012 */
00013 
00014 /**************************************************************************
00015 *   This program is free software; you can redistribute it and/or modify  *
00016 *   it under the terms of the GNU Library General Public License as       *
00017 *   published by the Free Software Foundation; either version 2.1 of the  *
00018 *   License, or (at your option) any later version.                       *
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    // reference the socket
00034    s->incref();
00035    m_recpt = recpt;
00036  
00037    m_trans->init( this );
00038    // not yet scheduled
00039    m_channel = 0;
00040    m_nextSchedule = -1;  
00041    m_line = 0;
00042 }
00043 
00044 Connection::~Connection()
00045 {
00046    // eventually inform the channel that we are out of business.
00047    if ( m_channel ) m_channel->deschedule( this );
00048    
00049    m_trans->terminate( this );
00050    
00051    // release the socket
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 /* end of cabal_conn.cpp */

Generated on Sat Apr 10 17:41:48 2004 for Cabal by doxygen 1.3.5