Relay.Calling.ConnectAction

View as Markdown

This object returned from connectAsync method that represents a connecting attempt that is currently active on a call.

Methods

getResult

Returns the final result of the connect attempt.

Returns

Relay.Calling.ConnectResult - Final result of the connect attempt.

Examples

Trying to connect two numbers in series and grab the result when it’s completed.

1<?php
2
3$devices = [
4 [ "type" => "phone", "to" => "+18991114444", "timeout" => 30 ],
5 [ "type" => "phone", "to" => "+18991114445", "timeout" => 20 ]
6];
7$call->connectAsync(...$devices)->done(function($action) {
8 // .. later in the code since it's an async method
9 if ($action->isCompleted()) {
10 $result = $action->getResult();
11 }
12});

getState

Return the current state of the connect attempt.

Returns

string - Current state of the connect attempt.

Examples

Trying to connect two numbers in series and print the state.

1<?php
2
3$devices = [
4 [ "type" => "phone", "to" => "+18991114444", "timeout" => 30 ],
5 [ "type" => "phone", "to" => "+18991114445", "timeout" => 20 ]
6];
7$call->connectAsync(...$devices)->done(function($action) {
8 echo $action->getState();
9});

getPayload

Return the payload sent to Relay to initiate the request. Useful to inspect what you sent to perform this action.

Returns

Object - Payload sent to Relay.

Examples

Trying to connect two numbers in series and print out the payload.

1<?php
2
3$devices = [
4 [ "type" => "phone", "to" => "+18991114444", "timeout" => 30 ],
5 [ "type" => "phone", "to" => "+18991114445", "timeout" => 20 ]
6];
7$call->connectAsync(...$devices)->done(function($action) {
8 print_r($action->getPayload());
9});

isCompleted

Return true if the connect attempt has finished, false otherwise.

Returns

Boolean - True/False accordingly to the state.

Examples

Trying to connect two numbers in series and check if it has finished.

1<?php
2
3$devices = [
4 [ "type" => "phone", "to" => "+18991114444", "timeout" => 30 ],
5 [ "type" => "phone", "to" => "+18991114445", "timeout" => 20 ]
6];
7$call->connectAsync(...$devices)->done(function($action) {
8 if ($action->isCompleted()) {
9
10 }
11});