Cisco Cisco Computer Telephony Integration Option 9.0 Developer's Guide
4-35
CTI OS Developer’s Guide for Cisco ICM/IPCC Enterprise & Hosted Editions
Cisco CTI OS Release 7.2(1)
Chapter 4 Building Your Application
Logging In and Logging Out an Agent
int nRetVal = m_ctiAgent->Logout(rArgAgentLogout);
rArgAgentLogout.Release();
}
2.
Receive a response for the Logout request.
You can expect the following events in response to a Logout request:
–
OnAgentStateChange (with Logout agent state)
or
OnControlFailure (with the reason for the failure).
–
OnPostLogout (you will additionally receive this event if the Logout request succeeds.
Note
Note that 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 CTIOS server requests in
response to the logout OnAgentStateChange event.
the OnAgentStateChange to logout state. Use the OnPostLogout event to trigger session
disconnect. This will guarantee that all event listeners can make CTIOS 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.