Picture of Carsten
Registered 2 years 274 days
Carsten Monday, 11 July 2022, 10:27 AM
Is it possible to call the RCC API from my service from Javascript?
I have written an app including a service that runs on the app platform.
Is it possible to call the RCC API from my service from Javascript? Is there an example service somewhere that illustrates the usage of RCC from Javascript service?
Thanks.

Andreas Fink
Moderator Registered 13 years 52 days
Andreas Fink (innovaphone) Monday, 11 July 2022, 01:17 PM
Re: Is it possible to call the RCC API from my service from Javascript?
Hello Carsten,

on the JavaScript App Service you have a possibility to use some libraries.

On https://sdk.innovaphone.com navigate to "Reference" / "JavaScript library for App Services" / "PbxApi". Here you will find documentation and general examples for usage of the PBX APIs.

After you have clarified how to start using a PBX API, you would need to read documentation of the specific PBX API you want to use. In your case it is RCC API. Navigate to "Reerence" / "APIs" / "PBX APIs" / "RCC" to see what messages are available and how to use this particular API.

Make sure the PBX App Object of your App has the flag "Websocket" activated, in order the PBX establish a WebSocket connection to the App Service. Also make sure to enable usage of the RCC API on this App Object (or any other API you want to use form this App Service).

The usage pattern of the RCC API would be following:
  • use Devices message to list all available devices of ta specific PBX user
  • perform UserInitilaize with specific Device
  • monitor CallInfo messages
  • or start calls via UserCall messages

A very simple example would look like this:
new PbxApi("RCC").onconnected(function (conn) {
 conn.send(JSON.stringify({ api: "RCC", mt: "Devices", cn: "Atlantis" }));
 conn.onmessage(function (msg) {
 var obj = JSON.parse(msg);
 if (obj.mt === "DevicesResult") {
 var hw = obj.devices.filter(function (device) { return device.text === "IP111" })[0];
 conn.send(JSON.stringify({ api: "RCC", mt: "UserInitialize", cn: "Atlantis", hw: hw } ));
 } else if (obj.mt === "UserInitializeResult") {
 conn.send(JSON.stringify({ api: "RCC", mt: "UserCall", user: obj.user, e164: "300" }));
 }
 });
});

The corresponding output on the App Service log:

AppWebsocket(001f98e0)::AppWebsocketMessageComplete connected:true
AppWebsocket(001f98e0)::AppWebsocketMessageSend {"api":"RCC","mt":"Devices","cn":"Atlantis"} connected:true
AppWebsocket(001f98e0)::WebsocketSendResult() connected=1 sendCount=1
AppWebsocket(001f98e0)::AppWebsocketRecvResult {"api":"RCC","mt":"DevicesResult","devices":[{"hw":"atlantis","text":""},{"hw":"009033288ac4","text":"IP111"},{"hw":"SwPh_afi_52bfa578","text":"myAppsSoft"}]}
AppWebsocket(001f98e0)::AppWebsocketMessageSend {"api":"RCC","mt":"UserInitialize","cn":"Atlantis","hw":{"hw":"009033288ac4","text":"IP111"}} connected:true
AppWebsocket(001f98e0)::AppWebsocketMessageComplete connected:true
AppWebsocket(001f98e0)::WebsocketSendResult() connected=1 sendCount=1
AppWebsocket(001f98e0)::AppWebsocketRecvResult {"api":"RCC","mt":"UserInitializeResult","user":1,"prefixIntl":"000","prefixNtl":"00","prefixSubs":"0","subscriber":"73009","area":"7031","country":"49"}
AppWebsocket(001f98e0)::AppWebsocketMessageSend {"api":"RCC","mt":"UserCall","user":1,"e164":"300"} connected:true
AppWebsocket(001f98e0)::AppWebsocketMessageComplete connected:true
AppWebsocket(001f98e0)::WebsocketSendResult() connected=1 sendCount=1
AppWebsocket(001f98e0)::AppWebsocketRecvResult {"api":"RCC","mt":"UserCallResult","call":2}
AppWebsocket(001f98e0)::AppWebsocketMessageComplete connected:true
AppWebsocket(001f98e0)::AppWebsocketRecvResult {"mt":"CallInfo","api":"RCC","user":1,"call":2,"state":1,"conf":"3b2a61c605cc62013410009033410fab","peer":{"e164":"300","h323":""},"time":0,"msg":"x-setup"}
AppWebsocket(001f98e0)::AppWebsocketMessageComplete connected:true
AppWebsocket(001f98e0)::AppWebsocketRecvResult {"mt":"CallInfo","api":"RCC","user":1,"call":2,"state":5,"peer":{"cn":"wq-wakemeup","dn":"wq-wakemeup","e164":"300","h323":"wq-wakemeup","norm":"300"},"time":0,"msg":"r-conn"}
AppWebsocket(001f98e0)::AppWebsocketMessageComplete connected:true
AppWebsocket(001f98e0)::AppWebsocketRecvResult {"mt":"CallInfo","api":"RCC","user":1,"call":2,"state":7,"peer":{"cn":"wq-wakemeup","dn":"wq-wakemeup","e164":"300","h323":"wq-wakemeup","norm":"300"},"time":24,"msg":"x-rel"}
AppWebsocket(001f98e0)::AppWebsocketMessageComplete connected:true
AppWebsocket(001f98e0)::AppWebsocketRecvResult {"mt":"CallInfo","api":"RCC","user":1,"call":2,"del":true,"state":7,"peer":{"cn":"wq-wakemeup","dn":"wq-wakemeup","e164":"300","h323":"wq-wakemeup"},"time":24,"msg":"del"}
AppWebsocket(001f98e0)::AppWebsocketMessageComplete connected:true

Best Regards
Andreas Fink
Picture of Carsten
Registered 2 years 274 days
Carsten Monday, 11 July 2022, 02:25 PM
Re: Is it possible to call the RCC API from my service from Javascript?
Thanks for pointing me into the right direction. Works like charm.

← You can define your color theme preference here