Picture of Khalil 5054
Registered 4 years 322 days
Khalil 5054 Monday, 3 August 2020, 01:15 PM
Using RCC api to make a call
Hi,

So I was given a list of how to do this:
  • Initialize - to setup a session
  • Devices - on specific User Object to get the list of Devices (in your case it will be Softwarephone hw)
  • UserInitilize - on this User Object, with provided hw, that was devlivered by previous Devices command. UserInitilize will deliver an id for User session
  • UserCall with id delivered by UserInitilize
I'm trying to follow the rcc api documentation https://sdk.innovaphone.com/doc/appwebsocket/RCC.htm but there is almost no examples on how to do this. Is it possible to get some help for this?
Picture of Khalil 5054
Registered 4 years 322 days
Khalil 5054 Tuesday, 4 August 2020, 02:00 PM
Re: Using RCC api to make a call
I am using the sample code rccapi.php to try to do the steps written above,
so far:
public function ReceiveInitialStart(\AppPlatform\Message $msg)
{
 $this->sendMessage(new AppPlatform\Message("Initialize", "api", "RCC"));
}

 public function ReceiveInitialUserInitialize(\AppPlatform\Message $msg)
{
 $this->sendMessage(new AppPlatform\Message("UserInitialize", "api", "RCC","cn","Khalil Abuawad", "hw", "SwPh_khalil.abuawad_5efef2f0"));
 $this->log("UserInitialize");
}

The problem is I can't seem to get the result from UserInitialize, I need the id for the user session, as needed for making the usercall but it only waits for InitalizeResult, and if InitalizeResult does not include return "dead" it times out. the whole class:
class PbxApiSample extends AppPlatform\FinitStateAutomaton
{

 public function ReceiveInitialStart(\AppPlatform\Message $msg)
{
 $this->sendMessage(new AppPlatform\Message("Initialize", "api", "RCC"));
}

 public function ReceiveInitialUserInitialize(\AppPlatform\Message $msg)
{
 $this->sendMessage(new AppPlatform\Message("UserInitialize", "api", "RCC","cn","Khalil Abuawad", "hw", "SwPh_khalil.abuawad_5efef2f0"));
 $this->log("UserInitialize");
}

 /* public function ReceiveInitialUserCall(\AppPlatform\Message $msg)
{
$this->sendMessage(new AppPlatform\Message("UserCall", "api", "RCC","user",2,"cn","Khalil Abuawad","e164","22795592"));
$this->log("UserCall");
}*/
 
 public function ReceiveInitialInitializeResult(\AppPlatform\Message $msg)
{
 $this->log("InitializeResult");
}
 
 public function ReceiveInitialUserInitializeResult(\AppPlatform\Message $msg)
{
 $this->log("UserInitializeResult");
 return "Dead";
}
 /* public function ReceiveInitialUserCallResult(\AppPlatform\Message $msg)
{
$this->log("UserCallResult");
 
}*/
 
}

Look screenshot for debug console output...


Screenshot_2020-08-04_at_14.00.23.png

Andreas Fink
Moderator Registered 13 years 110 days
Andreas Fink (innovaphone) Tuesday, 4 August 2020, 02:08 PM
Re: Using RCC api to make a call
Hello Khalil,

can i take a look on your configuration via AnyDesk?

Best Regards
Andreas Fink
Picture of Khalil 5054
Registered 4 years 322 days
Khalil 5054 Tuesday, 4 August 2020, 05:10 PM
Re: Using RCC api to make a call
Hi Andreas,

I was wondering, did you get to update the docs with an example of making a call with rcc api?

Sorry, but I prefer not, I can clarify my problem better if you would like to?
I am using the sample code rccapi.php to try to call using the softphone, my current problem is that I am not able to receive the user session id with UserInialize, I am quite new to php, and I would really much understand how to implement this or use the api with more examples of simple usage.

Edit: Sorry for late response..

Best Regards,
Khalil

Andreas Fink
Moderator Registered 13 years 110 days
Andreas Fink (innovaphone) Wednesday, 5 August 2020, 12:52 PM
Re: Using RCC api to make a call
Hello Khalil,


could you try this example and give feedback if it is understandable?

It will fetch all devices from User and take the first one. This Device is used in the UserInitilaize. Than a call to 91234 is started. After the call is connected and the CallInfo recived the state is changed to "Dead".

// the class utilizes the PbxApi
class PbxApiSample extends AppPlatform\FinitStateAutomaton {

public function ReceiveInitialStart(\AppPlatform\Message $msg) {
$this->sendMessage(new AppPlatform\Message("Initialize", "api", "RCC"));
}

public function ReceiveInitialUserInfo(\AppPlatform\Message $msg) {
$this->log("UserInfo");
}

public function ReceiveInitialInitializeResult(\AppPlatform\Message $msg) {
$this->log("InitializeResult: " . $msg->api);
$this->sendMessage(new AppPlatform\Message("Devices", "api", "RCC","cn","Andreas (Trainer)"));
}

public function ReceiveInitialDevicesResult(\AppPlatform\Message $msg) {
foreach( $msg->devices as $device) $hws[] = $device->hw;
$this->log("DevicesResult: " . implode($hws));
$this->sendMessage(new AppPlatform\Message("UserInitialize", "api", "RCC","cn","Khalil Abuawad", "hw", $hws[0]));
}

public function ReceiveInitialUserInitializeResult(\AppPlatform\Message $msg) {
$this->log("UserInitializeResult userid: " . $msg->user);
$userid = $msg->user;
$this->sendMessage(new AppPlatform\Message("UserCall", "api", "RCC","user", $msg->user, "e164", "91234"));
}

public function ReceiveInitialUserCallResult(\AppPlatform\Message $msg) {
$this->log("UserCallResult callid: " . $msg->call);
}

public function ReceiveInitialCallInfo(\AppPlatform\Message $msg) {
$this->log("CallInfo");
var_dump($msg);
if($msg->msg == 'r-conn' ) return "Dead";
}

}



← You can define your color theme preference here