Cisco Cisco Computer Telephony Integration OS 8.5 Developer's Guide
4-36
CTI OS Developer’s Guide for Cisco Unified ICM/Contact Center Enterprise & Hosted
Release 8.0(1)
Chapter 4 Building Your Application
Logging In and Logging Out an Agent
–
OnAgentStateChange (with Logout agent state)
or
OnControlFailure (with the reason for the failure).
or
OnControlFailure (with the reason for the failure).
–
OnPostLogout (you will additionally receive this event if the Logout request succeeds.
Note
You may disable statistics either prior to issuing the Logout request or upon receipt of the
OnAgentStateChange to logout state. Use the OnPostLogout event to trigger session disconnect.
This will guarantee that all event listeners can make CTI OS server requests in response to the
logout OnAgentStateChange event.
OnAgentStateChange to logout state. Use the OnPostLogout event to trigger session disconnect.
This will guarantee that all event listeners can make CTI OS server requests in response to the
logout OnAgentStateChange event.
See the following example code:
void CMyAppEventSink::OnPostLogout(Arguments & rArguments )
{
// Do not Disconnect if the reason code is Forced Logout
// (particular failover case):
int nAgentState = 0;
if ( rArguments.GetValueInt(CTIOS_AGENTSTATE, &nAgentState) )
{
if (nAgentState == eLogout)
{
int nReasonCode = 0;
if ( rArguments.GetValueInt(CTIOS_EVENTREASONCODE,
&nReasonCode) )
{
if (CTIOS_IPCC_FORCED_LOGOUT_REASON_CODE ==
(unsigned short)nReasonCode)
{
return;
}
}
}
}
//Disconnect otherwise
if( IsConnected() ) //if session is connected
{
if(m_ctiSession)
{
m_ctiSession->Disconnect();
}
}
}
3.
If you are not concerned with whether the agent is successfully logged out prior to disconnect, issue
a session Disconnect request without a Logout request.
a session Disconnect request without a Logout request.
4.
Additionally, you must wait for OnConnectionClosed before destroying Agent and Session objects.
This will guarantee that the CIL has completed cleanup of the Session object prior to your calling
Release on these objects.
This will guarantee that the CIL has completed cleanup of the Session object prior to your calling
Release on these objects.
5.
Ensure that the agent object is set to NULL in the session before you Release the session object. For
example, whenever your application is exiting and you are disconnecting the session object (e.g.
when the user closes your application's window) you should do something similar to the code below:
example, whenever your application is exiting and you are disconnecting the session object (e.g.
when the user closes your application's window) you should do something similar to the code below:
if (m_ctiSession)
{
m_ctiSession->Disconnect();
// stop all events for this session