Cisco Cisco Computer Telephony Integration Option 8.5 Developer's Guide

Page of 506
   
4-35
CTI OS Developer’s Guide for Cisco Unified Contact Center Enterprise
Release 8.5(1)
Chapter 4      Building Your Application
Logging In and Logging Out an Agent
How to Handle Duplicate Log In Attempts in the Desktop Application
If you detect from the OnQueryAgentStateConf() event that the agent is already logged in as described 
in the previous section, do the following:
If your custom_WarnIfAgentLoggedIn = 1 and custom_RejectIfAgentLoggedIn = 0, notify the user 
that the agent is already logged in and proceed with Login() depending on the user’s response.
If your custom_RejectIfAgentLoggedIn = 1, notify the user that the agent is already logged in and 
Disconnect.
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: