#include <transports.h>
Inheritance diagram for OpalListener:
Operations | |
enum | ThreadMode { SpawnNewThreadMode, HandOffThreadMode, SingleThreadMode } |
virtual BOOL | Open (const PNotifier &acceptHandler, ThreadMode mode=SpawnNewThreadMode)=0 |
virtual BOOL | IsOpen ()=0 |
virtual void | Close ()=0 |
virtual OpalTransport * | Accept (const PTimeInterval &timeout)=0 |
virtual OpalTransport * | CreateTransport (const OpalTransportAddress &localAddress, const OpalTransportAddress &remoteAddress) const=0 |
virtual OpalTransportAddress | GetLocalAddress (const OpalTransportAddress &preferredAddress=OpalTransportAddress()) const =0 |
OpalTransportAddress | GetTransportAddress () const |
void | CloseWait () |
void | CleanUpOnTermination () |
Public Member Functions | |
Overrides from PObject | |
void | PrintOn (ostream &strm) const |
Protected Member Functions | |
PDECLARE_NOTIFIER (PThread, OpalListener, ListenForConnections) | |
BOOL | StartThread (const PNotifier &acceptHandler, ThreadMode mode) |
Protected Attributes | |
OpalEndPoint & | endpoint |
PThread * | thread |
PNotifier | acceptHandler |
ThreadMode | threadMode |
The Main() function is used to handle incoming connections and dispatch them in new threads based on the actual OpalTransport class. This is defined in the descendent class that knows what the low level transport is, eg OpalListenerIP for the TCP/IP protocol.
An application may create a descendent off this class and override functions as required for operating the channel protocol.
OpalListener::OpalListener | ( | OpalEndPoint & | endpoint | ) |
Create a new listener.
endpoint | Endpoint listener is used for |
OpalListener::OpalListener | ( | OpalEndPoint & | endpoint | ) |
Create a new listener.
endpoint | Endpoint listener is used for |
void OpalListener::PrintOn | ( | ostream & | strm | ) | const |
Print the description of the listener to the stream.
virtual BOOL OpalListener::Open | ( | const PNotifier & | acceptHandler, | |
ThreadMode | mode = SpawnNewThreadMode | |||
) | [pure virtual] |
Open the listener. A thread is spawned to listen for incoming connections. The notifier function acceptHandler is called when a new connection is created. The INT parameter to the acceptHandler is a pointer to the new OpalTransport instance created by the listener. If this is NULL then it indicates an error occurred during the accept.
If singleThread is FALSE the acceptHandler function is called in the context of a new thread and the continues to listen for more connections. If TRUE, then the acceptHandler function is called from within the listener threads context and no more connections are created. That is only a single connection is ever created by this listener.
acceptHandler | Handler function for new connections |
mode | How handler function is called thread wise |
Implemented in OpalListenerTCP, and OpalListenerUDP.
virtual BOOL OpalListener::IsOpen | ( | ) | [pure virtual] |
Indicate if the listener is open.
Implemented in OpalListenerTCP, and OpalListenerUDP.
virtual void OpalListener::Close | ( | ) | [pure virtual] |
Stop the listener thread and no longer accept incoming connections.
Implemented in OpalListenerTCP, and OpalListenerUDP.
virtual OpalTransport* OpalListener::Accept | ( | const PTimeInterval & | timeout | ) | [pure virtual] |
Accept a new incoming transport.
timeout | Time to wait for incoming connection |
Implemented in OpalListenerTCP, and OpalListenerUDP.
virtual OpalTransport* OpalListener::CreateTransport | ( | const OpalTransportAddress & | localAddress, | |
const OpalTransportAddress & | remoteAddress | |||
) | const [pure virtual] |
Create a transport compatible with this listener.
Implemented in OpalListenerTCP, and OpalListenerUDP.
virtual OpalTransportAddress OpalListener::GetLocalAddress | ( | const OpalTransportAddress & | preferredAddress = OpalTransportAddress() |
) | const [pure virtual] |
Get the local transport address on which this listener may be accessed.
Implemented in OpalListenerIP.
OpalTransportAddress OpalListener::GetTransportAddress | ( | ) | const [inline] |
Get the local transport address on which this listener may be accessed. For backward compatibility with OpenH323, now deprecated.
void OpalListener::CloseWait | ( | ) |
Close channel and wait for associated thread to terminate.
void OpalListener::CleanUpOnTermination | ( | ) | [inline] |
Close channel and wait for associated thread to terminate. For backward compatibility with OpenH323, now deprecated.
OpalListener::PDECLARE_NOTIFIER | ( | PThread | , | |
OpalListener | , | |||
ListenForConnections | ||||
) | [protected] |
Handle incoming connections and dispatch them in new threads based on the OpalTransport class. This is defined in the descendent class that knows what the low level transport is, eg OpalListenerTCP for the TCP/IP protocol.
Note this function does not return until the Close() function is called or there is some other error.
BOOL OpalListener::StartThread | ( | const PNotifier & | acceptHandler, | |
ThreadMode | mode | |||
) | [protected] |
acceptHandler | Handler function for new connections |
mode | How handler function is called thread wise |
OpalEndPoint& OpalListener::endpoint [protected] |
PThread* OpalListener::thread [protected] |
PNotifier OpalListener::acceptHandler [protected] |
ThreadMode OpalListener::threadMode [protected] |