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";
}
}