Cisco Cisco Computer Telephony Integration Option 8.5 Developer's Guide

Page of 500
   
4-35
CTI OS Developer’s Guide for Cisco Unified ICM/Contact Center Enterprise & Hosted
Release 7.5(1)
Chapter 4      Building Your Application
Logging In and Logging Out an Agent
How to Log Out an Agent
To log out an agent:
Step 1
Create an instance of the Arguments class.
Step 2
Set log out values for the agent in the Arguments instance.
Note
Unified CC requires a reason code to log out. Other switches may have different 
requirements.
Step 3
Log out the agent.
The following example demonstrates this task in Java:
/* 1. Create Arguments object*/
Arguments rArgs = new Arguments();
/* 2. Set log out values.*/
rArgs.SetValue(CTIOS_EVENTREASONCODE, 1);
/* 3. Log out the agent.*/
int returnValue = agent.Logout(rArgs);
Typical Logout Procedure
When the Logout button is clicked – the following actions need to happen:
1.
Call  Logout request on your current agent.
You need to call Logout and not use SetAgentState(eLogout), because Logout provides additional 
logic to support pre-Logout notification, Logout failure notification, and resource cleanup.
Here’s the sample code for the same:
if(m_ctiAgent)
{
   Arguments &rArgAgentLogout = Arguments::CreateInstance();
   //add reason code if needed
   rArgAgentLogout.AddItem(CTIOS_EVENTREASONCODE, reasonCode);
   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.