Print Page | Close Window

OnCallConnected Never Fires

Printed From: Way2call Communications
Category: Hi-Phone Software Development Kit (SDK)
Forum Name: Hi-Phone and .NET
Forum Description: Discussion on the Hi-Phone product family, its .NET interface, samples and development tools
URL: http://www.way2call.com/forum/forum_posts.asp?TID=32
Printed Date: Oct 05 2024 at 6:31am


Topic: OnCallConnected Never Fires
Posted By: iurii
Subject: OnCallConnected Never Fires
Date Posted: Sep 03 2009 at 1:05pm
I dont know who to contact but the OnCallConnected event is never being raised.  Any ideas? Here is what I have so far:

Imports Way2call
Imports Way2call.Driver

Module Module1
    Dim w2cDrv As New CWay2callDriver() ' must be shared in classes

    Sub Main()

        Dim iErr As Integer = 0


        Console.WriteLine("Way2call .NET simple console application" & vbLf)
        Console.WriteLine("Initializing driver ..." & vbLf)

        ' add the event handler. note: it is static.
        'CWay2callDriver.OnNativeDeviceEvent += New CWay2callDriver.DelegateNativeDeviceEvent(CWay2callDriver_OnNativeDeviceEvent)

        'CWay2callDriver.OnCallConnected += New CWay2callDriver.DelegateNoParams(CWay2callDriver_OnCallConnected)

        AddHandler CWay2callDriver.OnNativeDeviceEvent, AddressOf CWay2callDriver_OnNativeDeviceEvent
        AddHandler CWay2callDriver.OnCallConnected, AddressOf OnCallConnected

        AddHandler CWay2callDriver.OnCallProgressSIT, AddressOf OnSitTriggered
        '     AddHandler CWay2callDriver.OnLineCurrentDrop, AddressOf OnLineDrop


        iErr = w2cDrv.InitializeDriver(0)
        'must be called
        If DirectCast(CWay2callDriver.Errors.SUCCESS, Integer) <> iErr Then
            Console.WriteLine("Error opening the Way2call driver ...: " + iErr.ToString())
            Return
        End If

        If 0 = w2cDrv.NumDevices Then
            Console.WriteLine("There are no Hi-Phone devices connected to this PC.")
            Return
        End If


        'assume device #0 exists
        iErr = w2cDrv.Device.Open(0)
        'open the device
        ' handle errors ...
        Console.WriteLine("Enter a number to call:")
        Dim sNumber As String = Console.ReadLine()


        Dim iToneId As CWay2callDriver.CDevice.TONE_MONITOR_IDS = CWay2callDriver.CDevice.TONE_MONITOR_IDS.TONE_ID_00
        w2cDrv.Device.ToneMonitor.Tone(iToneId).Duration = 3000
        w2cDrv.Device.ToneMonitor.Tone(iToneId).Frequency1 = 0
        w2cDrv.Device.ToneMonitor.Tone(iToneId).Frequency2 = 0
        w2cDrv.Device.ToneMonitor.Tone(iToneId).Frequency3 = 0
        w2cDrv.Device.ToneMonitor.Tone(iToneId).Enabled = True
        
        w2cDrv.Device.ToneMonitor.Start()
        
        ' the "w" means 'wait for dial tone'.
        iErr = w2cDrv.Device.[Call]("T," + sNumber, True, True)
        ' handle errors ...

        ' wait key press ...
        Console.WriteLine("Calling " + sNumber + ", Press any key to end ..." & vbLf & "  ")

        Console.ReadKey()

        iErr = w2cDrv.Device.Close(0)
        'close the device
        ' handle errors ...
        iErr = w2cDrv.ShutdownDriver(0)
        'must be last called
        ' handle errors ...
    End Sub

    Sub CWay2callDriver_OnNativeDeviceEvent(ByVal DeviceID As UShort, ByVal [Event] As UInteger, ByVal EventData As UInteger, ByVal EventDataEx As UInteger, ByVal pEventBuffer As Byte())
        'Dim w2cDrv As New CWay2callDriver()
        'print the event's description
        Console.WriteLine("{Event: " + w2cDrv.Device(DeviceID).EventDescription([Event], EventData) + "}")

    End Sub
    'Public Sub OnSitTriggered(ByVal DeviceID As UShort)
    '    Console.WriteLine("SIT Triggered")

    'End Sub


    Public Sub OnSitTriggered(ByVal DeviceID As UShort)
        Console.WriteLine("SIT Triggered")

    End Sub


    Public Sub OnCallConnected(ByVal DeviceID As UShort)
        'Dim w2cDrv As New CWay2callDriver() ' must be shared in classes

        'If 0 <> MyCallConnected Then
        '    Return
        'End If
        'event may be fired mutiple times
        'MyCallConnected = 1

        'mark call connected;
        ' unmute local device
        w2cDrv.Device.AudioControl.LocalDeviceToLine = CWay2callDriver.CDevice.CAudioControl.SIGNAL_SWITCH.UnMute

        ' connect local device to both line and PC audio
        w2cDrv.Device.SwitchingMode = CWay2callDriver.CDevice.SwitchingModes.Line_PcAudio_Phone


        ' Play a 'welcome' wave file message
        w2cDrv.Device.Audio.PlayWaveFile("c:\Welcome.wav", 0, w2cDrv.Device.Info.WaveOutDrvID)

    End Sub

End Module




Print Page | Close Window