How can I get the name associated with an extension/peer without having an opened channel with the Asterisk's Java API?

StackOverflow https://stackoverflow.com/questions/15513364

  •  24-03-2022
  •  | 
  •  

Question

I’m using FreePBX with Asterisk’s Java API. For the moment, I’m able to display all my SIP peers with their respective states:

public void onManagerEvent(ManagerEvent event) 
{
    // Look if the event is a IP phone (Peer entry)
    if(event instanceof PeerEntryEvent)
    {
        PeerEntryEvent ev = (PeerEntryEvent)event;
        // Get the user extension
        peer = ev.getObjectName();
        // Add to the array
        peersName.add(peer);
    }
}

enter image description here

I’m able to display the phone number and name of both callers when a channel is open:

private String GetExtensionPeer(String extension)
{
    for (AsteriskChannel e : channels)
        if (e.number.equals(extension) && e.bridge != null )
            for (AsteriskChannel channel : channels)
                if (z.channel.equals(e.bridge))
                   return "       with " + channel.number + " - " + channel.name;
    return "";
}

enter image description here

But now, I would like to display the name of my extensions without a channel connection.

In FreePBX's panel, it's look like :

enter image description here

Was it helpful?

Solution

In freepbx you can get list of extensions from asterisk db. To see info, do

asterisk -rx "database show"

To get info use manager action "command" with DBGET.

Other option - got that info from freepbx's mysql db.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top