Cisco Cisco Computer Telephony Integration Option 9.0 Developer's Guide

Page of 500
   
2-5
CTI OS Developer’s Guide for Cisco ICM/IPCC Enterprise & Hosted Editions
Cisco CTI OS Release 7.2(1)
Chapter 2      CTI OS Client Interface Library Architecture
CIL Object Model
Object Creation and Lifetime
The Session object maintains a collection for each class of objects it manages (e.g. Agents, Calls, 
SkillGroups, etc.). 
Objects are created either by the programmer, or by the Session object as required to support the event 
flow received from the CTIOS Server. In Agent Mode, the programmer will create a single Agent object 
with which to login, whereas in Monitor Mode, Agent objects are created as required by the event flow. 
Call and SkillGroup objects are always created by the Session object.
An Agent, Call or SkillGroup object is created (by the Session) when the Session receives an event for 
an object (identified by its UniqueObjectID) that is not yet present at the CIL. This ensures that the CIL 
will always have the appropriate collection of proxy objects, one for each object on the CTIOS Server 
that it is using. When a new object is created, it is added to the Session object’s collection, and is 
accessible from the Session via the GetValue mechanism. See 
Reference Counting
Object lifetime is controlled using reference counting. Reference counts determine if an object is still in 
use; that is, if a pointer or reference to it still exists in some collection or member variable. When all 
references to the object have been released, the object is deleted. 
An application or object that will hold a reference to a CIL object must add to its reference count using 
the AddRef method. When the reference is no longer required, the application or object holding that 
reference must decrement the reference count using the Release() method. Reference counting is 
discussed further in 
Note
Reference counting must be done explicitly in C++ applications (COM or non-COM). Visual Basic, 
Java, and the .NET frameworkwill perform automatic reference counting. 
Call Object Lifetime
Call objects are created at the CIL in response to events from the CTIOS server. Usually, a Call object 
will be created in response to the OnCallBegin event, but in certain failover recovery scenarios a Call 
object could be created in response to an OnSnapshotCallConf event. Any call data available for the call 
is passed in the event, and is used to set up the Call object’s initial state and properties. 
The Call object will remain valid at the CIL until the receipt of the OnCallEnd event. When the 
OnCallEnd event is received, the Session object will publish the event to any subscribers to the event 
interfaces. Applications and objects must release any remaining references to the Call object within their 
event handler for OnCallEnd to allow the Call object to be properly deleted.  When the Call object’s 
OnEvent method returns after handling OnCallEnd, the Session will check the reference count for zero; 
if any references remain, the call object will be removed from the call object collection but will not be 
deleted until the last reference to it is released.
Agent Object Lifetime
In Agent Mode, the client programmer must create an Agent object (which causes its reference count to 
be incremented to one) and must pass it to the Session in the SetAgent method.