Cisco Cisco Computer Telephony Integration Option 8.5 Developer's Guide

Page of 500
   
4-28
CTI OS Developer’s Guide for Cisco ICM/IPCC Enterprise & Hosted Editions
Cisco CTI OS Release 7.2(1)
Chapter 4      Building Your Application
Connecting to the CTI OS Server
The request for desktop settings can be made either in the OnConnection event or in the 
OnSetAgentModeEvent
 event (if Agent mode has been specified). Sample code:
Private Sub m_Session_OnConnection(ByVal pDispParam As Object)
'Issue a request to the server to send us all the Desktop 'Settings
m_Session.RequestDesktopSettings eAgentDesktop
 
End Sub
The OnGlobalSettingsDownloadConf event passes back the settings and they can be accessed 
via the Session object. For example, the following snippet checks for Sound Preferences and specifically 
to see if the Dial Tone is Mute or not:
Private Sub m_session_OnGlobalSettingsDownloadConf(ByVal pDispParam As Object)
Dim SoundArgs As CTIOSARGUMENTSLib.Arguments
' check if "SoundPreferences is a valid property
   
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 may abort these requests. For example, calling 
Disconnect immediately after calling Logout may 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: