Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

API call returns only first character of data

$
0
0
Hello,

I am working on creating a console application to interface with our Nortel BCM 50 Call Detail Recording.
Sample code is provided by Nortel; however, it is based in VB6 (I believe) and I am having some trouble getting the API calls to work properly in VB.net
The problem is that I am supposed to receive a long string of text which includes incoming phone numbers and time stamps; however I am only receiving the very first character. An example string is supposed to look like "*121912 161428 0126 394 9999999999 UNKNOWN U R" where 9999999999 is a phone number, my code though only returns "*". The application is also supposed to receive multiple lines of this information in rapid succession, but it seems as though the API stops after the first character.

The API in question is "VBCdrOpenConnection" which is supposed to call the function "CDRRecord" with new data.

Another (possibly unrelated) question is how would I go about keeping a console application constantly running and waiting for input from the API without using something like "Console.ReadLine()" (the console app will never have user interaction).

Please find below my VB.net code. If it is required I can provide the original VB6 sample code.

Option Explicit On
Imports System.Threading
Imports System.Windows.Forms

Module CDR
    Declare Function VBCdrOpenConnection Lib "CDRClient.dll" (ByVal IPAddressOrMachineName As String, ByVal usernameOfCDRUserGroup As String, ByVal Password As String, ByVal CDRRecord As CDRRecordHandler, ByVal CDRStop As CDRStopHandler, ByVal applicationData As Integer) As Short
    Public Delegate Sub CDRRecordHandler(ByVal bStrMsg As String, ByVal applicationData As Integer)
    Public Delegate Sub CDRStopHandler(ByVal Reason As Integer, ByVal applicationData As Integer)
    Declare Function CdrCloseConnection Lib "CDRClient.dll" (ByVal Handle As Short) As Short
    Declare Function CdrClipFile Lib "CDRClient.dll" (ByVal Handle As Short) As Short

    'variables emptied for security purposes
    Const MAX_COUNT = 50
    Const BCM_ADDRESS = ""
    Const BCM_USER = ""
    Const BCM_PASS = ""

    Public CDRCount As Integer
    Public Handle As Integer

    Public Sub CDRRecord(ByVal bStrMsg As String, ByVal applicationData As Integer)
        CDRCount = CDRCount + 1
        MessageBox.Show(applicationData)
        appendText(bStrMsg)
    End Sub

    Public Sub CDRStop(ByVal Reason As Integer, ByVal applicationData As Integer)
        CDRCount = 0
        appendText(" stop reason " & CStr(Reason) & vbCrLf & "Disconnected" & vbCrLf)
    End Sub

    Public Sub appendText(ByVal msg As String)
        If (CDRCount > MAX_COUNT) Then
            Console.Clear()
        End If
        'MessageBox.Show(msg)

        Console.WriteLine(msg)
        Console.ReadLine()
    End Sub

    Declare Function SetConsoleCtrlHandler Lib "kernel32.dll" (ByVal HandlerRoutine As ControlEventHandler, ByVal Add As Int32) As Int32
    Public Delegate Sub ControlEventHandler(ByVal consoleEvent As ConsoleEvent)

    Public Enum ConsoleEvent
        CTRL_C = 0
        CTRL_BREAK = 1
        CTRL_CLOSE = 2
        CTRL_LOGOFF = 5
        CTRL_SHUTDOWN = 6
    End Enum

    Public Sub OnControlEvent(ByVal consoleEvent As ConsoleEvent)
        Handle = CdrCloseConnection(Handle)
        appendText("Disconnected" & vbCrLf)
        Handle = -1
    End Sub

    Sub Main()
        SetConsoleCtrlHandler(New ControlEventHandler(AddressOf OnControlEvent), True)

        CDRCount = 0
        Handle = VBCdrOpenConnection(BCM_ADDRESS, BCM_USER, BCM_PASS, New CDRRecordHandler(AddressOf CDRRecord), New CDRStopHandler(AddressOf CDRStop), 0)

        If Handle <> -1 Then
            appendText("Connected to " & BCM_ADDRESS & vbCrLf)
            'Thread.Sleep(10000)
        Else
            appendText("Failed to connect to " & BCM_ADDRESS & vbCrLf)
        End If
    End Sub
End Module


Any help with this would be greatly appreciated!

Thank you,
Daniel

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>