Cisco Cisco Computer Telephony Integration Option 8.5 Developer's Guide

Page of 490
   
4-29
CTI OS Developer’s Guide for Cisco Unified Contact Center Enterprise
Release 8.5(3)
Chapter 4      Building Your Application
Connecting to the CTI OS Server
   
If m_session.IsValid("SoundPreferences ") = 1 Then
  Set SoundArgs = m_session.GetValue("SoundPreferences")
  Dim DialToneArgs As CTIOSARGUMENTSLib.Arguments
   If Not SoundArgs Is Nothing Then
      If SoundArgs.IsValid("DialTone") = 1 Then
          Set DialToneArgs = SoundArgs.GetValue("DialTone")
      End If
   End If
       
   Dim Mute As Integer
   If Not DialToneArgs Is Nothing Then    
     If DialToneArgs.IsValid("Mute") = 1 Then
       Mute = DialToneArgs.GetValueInt("Mute")
       If Mute = 1 Then
         MsgBox "Dial Tone MUTE"//Your logic here
       Else
         MsgBox "Dial Tone  NOT MUTE"//Your logic here
       End If
     End If
End If
End If
End Sub
Disconnecting from CTI OS Server
Disconnecting from CTI OS Server (via the Disconnect() method) before shutting down is an 
important part of the client application functionality. The Disconnect() method closes the socket 
connection between the client application and CTI OS. On most switches, it does not log the agent out. 
If no 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 abort these requests. For example, calling Disconnect 
immediately after calling Logout can 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 CTI OS Server when the session mode has not yet 
been established by means of calling either CCtiOsSsession::SetAgent(...) or  
CCtiOsSsession::SetMessageFilter(...), you must call for disconnect with an arguments array containing 
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);