Results 1 to 9 of 9

Thread: VB.NET and AsterNet

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2011
    Posts
    256

    VB.NET and AsterNet

    Hi guys,
    Does anyone here know anything about AsterNet (.NET for Asterisk) ?
    Thanks

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: VB.NET and AsterNet

    Rather than asking whether anyone knows anything, you should probably explain what it is that you actually want to do and then you can find out whether anyone knows that specifically.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    May 2011
    Posts
    256

    Re: VB.NET and AsterNet

    Quote Originally Posted by jmcilhinney View Post
    Rather than asking whether anyone knows anything, you should probably explain what it is that you actually want to do and then you can find out whether anyone knows that specifically.
    Good idea...
    So here is what I'm trying to do
    1. Connect to my Asterisk
    2. Pull a list of all "Registered" extensions
    3. Get labels for each extension (automatically added) so I will not need to modify the code for each new extension

    I managed to connect with no problem, here is my code:
    Code:
    Imports AsterNET
    Imports AsterNET.Manager
    Imports AsterNET.Manager.Event
    Imports AsterNET.FastAGI.Command
    Imports AsterNET.FastAGI
    Imports AsterNET.IO
    Imports System.Text
    Imports System.Data.Sql
    
    
    Public Class Form1
        Dim host As String = "192.168.1.2"
        Dim port As Short = 5038
        Dim user As String = "AMIuser"
        Dim pass As String = "password"
        Dim conn As New ManagerConnection(host, port, user, pass)
        Dim exten As Short
        Dim state As String = "state"
    
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Label1.Text = state
            Logoffbtn.Enabled = False
        End Sub
    
        Private Sub Loginbtn_Click(sender As Object, e As EventArgs) Handles Loginbtn.Click
            Try
                conn.Login()
    
            Catch ex As Exception
                MsgBox("Error logging on")
    
            End Try
            Label1.Text = conn.IsConnected
            If Label1.Text = "True" Then
                Loginbtn.Enabled = False
                Logoffbtn.Enabled = True
            End If
        End Sub
    
    
        Private Sub Logoffbtn_Click(sender As Object, e As EventArgs) Handles Logoffbtn.Click
            Try
                conn.Logoff()
            Catch ex As Exception
                MsgBox("Error logging off")
    
            End Try
    
            Label1.Text = conn.IsConnected
            If Label1.Text = "False" Then
                Loginbtn.Enabled = True
                Logoffbtn.Enabled = False
            End If
        End Sub
    But after that, I can't figure it out...
    I have a ListBox that I need to fill with the "Registered" extensions
    And for every line in the ListBox it needs to generate a label (this I didn't figure out also)

    Thanks for any help I can get...

  4. #4
    New Member
    Join Date
    Apr 2017
    Posts
    4

    Re: VB.NET and AsterNet

    Hello, did you solve the question?
    I'm trying to receive the events from asterisk just now with no result.
    Can you help me?

    Thanks!

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    May 2011
    Posts
    256

    Re: VB.NET and AsterNet

    Quote Originally Posted by jajiro View Post
    Hello, did you solve the question?
    I'm trying to receive the events from asterisk just now with no result.
    Can you help me?

    Thanks!
    Hi,
    No, I did not solve it
    but what are you trying to do?

  6. #6
    New Member
    Join Date
    Apr 2017
    Posts
    4

    Re: VB.NET and AsterNet

    Quote Originally Posted by threeeye View Post
    Hi,
    No, I did not solve it
    but what are you trying to do?
    Hi,
    I'm trying to connect with the asterisk server and receive data from VoIP calls.
    At then moment I can connect and disconect but I don't know how can I receibe information about the received calls (the number, duration, ...)
    I think that my problem is about catch the events but i'm lossing

    Thanks for your help.

  7. #7
    New Member
    Join Date
    Apr 2017
    Posts
    4

    Re: VB.NET and AsterNet

    Any idea?

  8. #8
    Frenzied Member
    Join Date
    May 2014
    Location
    Central Europe
    Posts
    1,372

    Re: VB.NET and AsterNet

    i have got no idea about this stuff but just googled ManagerConnection and found this: https://maven.reucon.com/projects/pu...onnection.html

    It suggests that you Need to call addEventListener(ManagerEventListener eventListener)

    so i'd start off adding a new class inheriting from ManagerEventListener overriding onManagerEvent and call addEventListener with this class.

  9. #9
    New Member
    Join Date
    Apr 2017
    Posts
    4

    Re: VB.NET and AsterNet

    Thanks four your help, now I can receive de NewState event. Now Im trying to make a call but I receive the responde "Extension does not exists".
    This is the code:

    Private WithEvents Manager As New AsterNET.Manager.ManagerConnection(host, port, user, pass)

    ...

    Manager.Login()
    Dim test As New Action.OriginateAction

    Manager.UseASyncEvents = True

    test.Server = host

    test.Channel = "PJSIP/trunk_2-000000f4"
    test.CallerId = "Test"
    test.Exten = "123456789" ' Phone number
    test.Priority = 1
    test.Context = "default"
    test.Timeout = 30000
    test.Async = True

    Dim originateResponse As ManagerResponse = Nothing

    originateResponse = Manager.SendAction(test, 30000)

    ? donĀ“t know why that extension does not exists because if I call to the VoIP server, in the NesState event, the property e.Channel is the same.

    Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width