Jump to content
Vodia PBX forum
nalakag

API Call to get Currently Active Calls

Recommended Posts

Yes. You can use the REST interface for this. If you want to know how it works, just use your web browser and watch the traffic between the PBX and the browser. It is based on websocket, which triggers the actual REST transaction. You can use Basic authentication instead of logging in if you want to use an external program like curl.

Share this post


Link to post
Share on other sites

Hi,

 

I've opened a connection to the server using a websocket in a client agent and then I send request with the following json object in the body.

 

- {"action":"get-calls"}

 

However, nothing is received in the onmessage method on the websocket client, even though there are new and existing active calls. Also, there are no errors returned from the server.

 

Default page when I login using a browser - http://<server url>/reg_domains.htm

 

- The websocket connects to ws://<server url>/

 

Is the server url that I am connecting to and the json message correct?

 

Is there any documentation about the api calls/actions accessible via web sockets?

 

Thanks

Nalaka

Share this post


Link to post
Share on other sites

Well if there is no change with the calls you would not get any traffic on websocket. Websocket is really just to tell the browser that something has changed, but not what has changed. For that the browser will make a (non-websocket) standard REST call. Try to watch the traffic when there is a call coming into the system, or when someone hangs up. I think then you will understand the logic better.

Share this post


Link to post
Share on other sites

Hi Admin,

 

Perhaps you are describing something else. I am trying to replicate the behaviour on the Status -> Active Calls page on Vodia PBX Hosted 5.2.2c, on a rich client. Initially, there is a REST call made to load the page contents. However, after that all the data related to call statuses seem to be communicated over a websocket.

 

I am confused as to why the onopen phase is successful and the onmessage phase does not get called, on my rich client. It is working on the webpage loaded from the PBX Server. Is the communication between the websockets (i.e. PBX server and PBX webpage) taking place over a custom channel?

 

Thanks

Nalaka

Share this post


Link to post
Share on other sites

No, everything should be visible in the browser. We are mostly using Chrome, where you can see the traffic between the PBX and the browser nicely listed at the bottom. If it is still not clear, you can as well use Wireshark to see what is going on on the network level (use HTTP instead of HTTPS).

Share this post


Link to post
Share on other sites

Hello,

I tried the same thing by opening up websocket connection with javascript.

The problem is when websocket handshake with PBX, PBX requested session token but you can't set header in websockets.

 

To test it try this: (just to test)

Login into PBX as admin in one tab and then open another tab with your javascript websocket code. Make call after that you should get messages from PBX server in Chrome frames.

 

But there is one more solution and that is make http call to get session token like this (but doesn't work). Than open websocket and it should have session token.

Share this post


Link to post
Share on other sites

You can set the authentication also with websockets; just watch what the browser is doing. We could add something with websockets that checks the authentication and set up the session for you; but the question is if that would really help you.

Share this post


Link to post
Share on other sites

Not sure if it possible to set header parameters in websocket call according :

Authorization and websockets headers

 

If we could figure out http login with ajax (from different origin) or work around CORS could help.

 

Like I am trying to do in this post : javascript Rest api

 

This will be possible if you guys can all API access list in 'Access-Control-Allow-Origin: IP' in header

Example from Here

 

 

 

Then it will be alot easy to setup websocket connection by first making the HTTP request and websocket Handshake.

Share this post


Link to post
Share on other sites

I fully agree, but to get live steam of active calls and active calls is important with off-course some limits and boundaries.

 

Thanks for your help

Best Regards

Share this post


Link to post
Share on other sites

In the mean time what you can do is override some functionality of our JS files by putting a copy of the file by the same name in the the html folder. The pbx will then use the javascript file instead where you can make changes. Changes like posting the results of active calls to any server (since POST allows cross origins).

 

This should help you for now.

 

Thanks.

Share this post


Link to post
Share on other sites

Thanks

 

That's exactly I was going for after server to server websocket client solution. I uploaded those files Here.

 

 

But one another thing I am wonder would make things easy if I could get status of all extension status at domain level.

 

Now, I have to login into ext account to find the status and it only give user-state for the account which I am logging as. Its will be great I could get status of all extension in one output.

{"action":"user-state","type":"extensions","account":"101", "code":"ringback", "chatstatus":"online"}

Best Regards

Share this post


Link to post
Share on other sites

The next version will include a new WebRTC client in the user mode. It is not JSSIP compliant, and probably not even SIP compliant, but it uses websocket and the WebRTC API to make things happen. The end user does not care (as long as it works). The RFC is on our radar, and eventually we will "drift" in to that direction.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...