Cisco Cisco Computer Telephony Integration OS 8.5 Developer's Guide

Page of 640
 
4-41
CTI OS Developer’s Guide for Cisco ICM/IPCC Enterprise & Hosted Editions Release 7.0(0)
 
Chapter 4      Building Your Application
Connecting to the CTI OS Server
logout request was issued before the Disconnect(), then on most switches the 
agent stays logged into the instrument even after the client application has shut 
down. 
Note
Disconnect is a higher priority method than all others. Before calling Disconnect, 
ensure that all prior requests have completed lest the call to Disconnect may abort 
these requests. For example, calling Disconnect immediately after calling Logout 
may result in an agent not being logged out.
Upon Disconnect(), each object maintained by the Session (Call, Skillgroup, 
Wait) is released and no further events are received. Cleaning up the Agent object 
is the developer’s responsibility since it was handed to the Session (via the 
SetAgent()
 method.
Code sample:
In the C++ and COM CIL  Only, To disconnect from CTIOS Server when the 
session mode has not yet been established by means of calling either 
CCtiOsSsession::SetAgent(...) or  CCtiOsSsession::SetMessageFilter(...), 
Disconnect must be called with an arguments array that contains the 
CTIOS_FORCEDDISCONNECT set to True.
m_session.Disconnect
// Perform disconnect
if(m_ctiSession->GetValueInt(CTIOS_CONNECTIONMODE) == 
eSessionModeNotSet )
{  // If the session mode has not yet been set by SetAgent or
                           // SetSessionMode at the time of the 
disconnect.
   // we need to indicate the session that a disconnect needs 
to
   
   // be forced
   bool    bAllocOk = true;
   Arguments * pDisconnectArgs = NULL;
   bAllocOk = Arguments::CreateInstance(&pDisconnectArgs);
   
   if ((false==bAllocOk) || (pDisconnectArgs == NULL))
   {
   CDialog::OnClose();
   argsWaitParams.Release();
   return;
   }
   pDisconnectArgs->AddItem(CTIOS_FORCEDDISCONNECT,true);
   m_ctiSession->Disconnect(*pDisconnectArgs);