connmgr.h
资源名称:h323.zip [点击查看]
上传用户:hnnddl
上传日期:2007-01-06
资源大小:3580k
文件大小:6k
源码类别:
IP电话/视频会议
开发平台:
WINDOWS
- /*
- * $Revision: 1.4 $
- * $Date: 1998/04/03 15:16:33 $
- */
- ////////////////////////////////////////////////////////////////
- // Copyright (c) 1996,97 Lucent Technologies //
- // All Rights Reserved //
- // //
- // THIS IS UNPUBLISHED //
- // PROPRIETARY SOURCE //
- // CODE OF Lucent Technologies //
- // AND elemedia //
- // //
- // The copyright notice above does not evidence any //
- // actual or intended publication of such source code//
- ////////////////////////////////////////////////////////////////
- //
- /////////////////////////////////////////////////////////////////
- // File : connmgr.h //
- // //
- // This file declares the ConnectionManager class. //
- // //
- // History: //
- // //
- // 01_Apr_1997 Created //
- // 01_Jul_1997 Added GetConnectionAddrs method in //
- // ConnectionEntity class. //
- // 10_Dec_1997 Made destructors virtual. //
- // //
- /////////////////////////////////////////////////////////////////
- #if (!defined(__CONNMGR_H__))
- #define __CONNMGR_H__
- #include "api/connmgrerr.h"
- #include "util/platform.h"
- // Specifies the action taken by Listen. If LT_ONCE is specified,
- // the listening socket is closed after the first accept. If LT_MANY
- // is chosen, the listening socket is kept open to accept more than one
- // incoming connection.
- enum ListenType
- {
- LT_ONCE,
- LT_MANY
- };
- class ConnectionManager;
- class TransDataCallBack;
- class TransCtrlCallBackClient;
- class Trans;
- class Logger;
- // The ConnectionEntity class. Users must derive their protocol
- // classes H245Protocol and H225CSProtocol from ConnectionEntity class.
- // Note that the destructor closes the connection automatically, so
- // there is no need to explicitly call ConnectionManager::CloseConnection for
- // connections created using the ConnManager::AcceptConnection or
- // ConnManager::Connect calls.
- class DLLEXPORT ConnectionEntity
- {
- public:
- //
- // The identifier in connection entity, is used to differentiate
- // one instance of the ConnectionEntity object from the other.
- //
- ConnectionEntity(int identifier);
- virtual ~ConnectionEntity();
- int GetIdentifier();
- int IsConnectionReady();
- // Method returns the local and remote addresses for the
- // connection.
- ProtReturnCode GetConnectionAddrs(sockaddr *local_addr,
- sockaddr *remote_addr);
- protected:
- TransDataCallBack *GetDataCallBack();
- void SetDataCallBack(TransDataCallBack *cb);
- virtual int GetLLC();
- private:
- friend class ConnectionManager;
- friend class TransCtrlCallBackClient;
- int llc;
- int identifier;
- TransDataCallBack *data_callback;
- int is_data_connection_ready;
- virtual void SetLLC(int llc);
- virtual void DataConnectionReady();
- virtual void DataConnectionDown();
- };
- // The connection manager class manages the interface to the transport layer.
- // It handles all control functions of the connection, like listen connect,
- // accept and close. The Data transfer functions for a connection are enabled,
- // if a connection entity class associated with that connection. This is
- // done either in Connect or the AcceptConnection call.
- class DLLEXPORT ConnectionManager
- {
- public:
- // Note: Make sure that you explicitly disable all listens
- // using StopListening routine before destroying the object.
- ConnectionManager(ProtReturnCode &result);
- virtual ~ConnectionManager();
- ProtReturnCode Connect(struct sockaddr* remote_address,
- ConnectionEntity* conn);
- // listen_type is one of ListenType. If listen_type is LT_ONCE
- // then after accepting exactly one connection the listening
- // socket is closed, otherwise the socket is kept open to
- // accept many new connections.
- // If multiple Listens are called, then identifier is passed back
- // in NotifyNewConnection and this is used to identify which one
- // of the listens did the accept.
- ProtReturnCode Listen(int identifier, struct sockaddr* local_address,
- int listen_type);
- // Disable an already existing listen. This will close the listening
- // socket. Use the identifier field, to specify which listen to
- // disable. To reenable listen, make another call to Listen.
- ProtReturnCode StopListening(int identifier);
- // Call this to accept an incoming connection. Typically this
- // call is made after a NotifyNewConnection call from the
- // stack. Pass down the same conn_ref that came in the notification.
- ProtReturnCode AcceptConnection(int conn_ref, ConnectionEntity* conn);
- // Call this to reject an incoming connection. This call is made
- // after a NotifyIncomingConnection call from the stack. Pass
- // down the same conn_ref that came in the notification.
- ProtReturnCode RejectConnection(int conn_ref);
- // Use this to close a connection identified by the ConnectionEntity.
- // This would be the same entity that was passed in AcceptConnection
- // or in Connect.
- ProtReturnCode CloseConnection(ConnectionEntity* conn);
- // Notifications to be implemented by the user of this class.
- // Notify a new incoming connection.
- // This is called, when a Listen succeeds, and the stack calls
- // an accept. The identifier is the same one that was passed
- // down in the Listen call. This is used by the application
- // to identify which one of the many multiple listens accepted
- // the new connection.
- virtual void NotifyNewConnection(int identifier, int conn_ref,
- sockaddr* remote_address) = 0;
- // This method is called when a Connect either
- // fails or succeeds.
- virtual void NotifyConnectionStatus(ConnectionEntity *conn,
- ProtReturnCode connection_status) = 0;
- // An already existing connection has been closed
- // by the remote end.
- virtual void NotifyConnectionClosed(ConnectionEntity *conn,
- ProtReturnCode status) = 0;
- // Error occured while trying to accept an incoming
- // connection (as a result of a earlier Listen call.)
- virtual void NotifyListenError(int identifier,
- ProtReturnCode status) = 0;
- private:
- TransCtrlCallBackClient* ctrl_cb_client;
- int client_handle;
- Logger* _logger;
- };
- #endif