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

IncomingScript Class Reference

Incoming call handling. One object for each incoming call is created. More...

#include <incomingscript.h>

Inheritance diagram for IncomingScript:

PythonScript List of all members.

Public Member Functions

 IncomingScript (ostream &debug, unsigned short debug_level, ostream &error, Connection *conn, string incoming_script, PycStringIO_CAPI *cStringIO) throw (ApplicationError)
 Constructor. Create Object and start detached thread.
virtual ~IncomingScript ()
 Destructor. Destruct object and assure the call is disconnected.

Private Member Functions

virtual void run (void) throw ()
 Thread body. Calls the python function callIncoming() which will handle the call.

Private Attributes

Connectionconn
 reference to according connection object
pthread_t thread_handle
 handle for the created pthread thread

Friends

void * incomingscript_exec_handler (void *)
 Thread exec handler for IncomingScript class.
void incomingscript_cleanup_handler (void *)
 Thread clean handler for IncomingScript class.

Detailed Description

Incoming call handling. One object for each incoming call is created.

IncomingScript handels an incoming connection. For each connection, one object of it is created by FlowControl. It mainly creates a new thread with an own python subinterpreter, initializes the capisuitemodule, and calls run() of PythonScript which will execute the defined function in the script.

Author:
Gernot Hillier


Constructor & Destructor Documentation

IncomingScript::IncomingScript ostream &  debug,
unsigned short  debug_level,
ostream &  error,
Connection conn,
string  incoming_script,
PycStringIO_CAPI *  cStringIO
throw (ApplicationError)
 

Constructor. Create Object and start detached thread.

Parameters:
debug stream for debugging info
debug_level verbosity level for debug messages
error stream for error messages
conn reference to according connection (disconnected if error occurs)
incoming_script file name of the python script to use as incoming script
cStringIO pointer to the Python cStringIO C API
Exceptions:
ApplicationError Thrown if thread can't be started

IncomingScript::~IncomingScript  )  [virtual]
 

Destructor. Destruct object and assure the call is disconnected.


Member Function Documentation

void IncomingScript::run void   )  throw () [private, virtual]
 

Thread body. Calls the python function callIncoming() which will handle the call.

Create python sub-interpreter, read script for incoming calls,

The read Python script for incoming calls must provide a function named callIncoming with the following signature:

def callIncoming(call, service, callingParty, calledParty): # function body

The parameters given to the python function are:

  • call: reference to the incoming call. Must be given to all capisuite-provided python functions as first parameter.
  • service (integer): service as signalled by ISDN, set to one of the SERVICE_* constants defined in capisuitemodule_init
  • callingParty (string): the number of the calling party (source of the call)
  • calledParty (string): the number of the called party (destination of the call)

At the moment callIncoming() is called, the call is waiting for an answer, so the first thing the script must do is to call connect_*() or reject(). It must also disconnect the call in any case (even in the exception handlers!) before finishing using disconnect().

If the call is disconnected by the other party, the Python exception CallGoneError is raised and should be caught by the script (but even there you must call disconnect()).

The python global lock will be acquired while the function runs.

Reimplemented from PythonScript.


Friends And Related Function Documentation

void incomingscript_cleanup_handler void *   )  [friend]
 

Thread clean handler for IncomingScript class.

This is a handler which is called by pthreads at cleanup. It will call this->final().

void* incomingscript_exec_handler void *   )  [friend]
 

Thread exec handler for IncomingScript class.

This is a handler which will call this->run() for the use in pthread_create(). It will also register incomingscript_cleanup_handler


Member Data Documentation

Connection* IncomingScript::conn [private]
 

reference to according connection object

pthread_t IncomingScript::thread_handle [private]
 

handle for the created pthread thread


The documentation for this class was generated from the following files:
Generated on Sun Nov 28 14:37:45 2004 for CapiSuite by doxygen 1.3.8