Skip to main content

Relay.Calling.TapAction

This object returned from tapAsync method that represents the running media tapping active on a call.

Methods

getControlId

Return the UUID to identify the action.

Available In:

Parameters

None

Returns

string - UUID to identify the action.

Examples

Start tapping audio and print the controlId.
<?php

$tap = [
'target_type' => 'rtp',
'target_addr' => '192.168.1.1',
'target_port' => 1234
];
$call->tapAsync($tap)->done(function($action) {
echo $action->getControlId();
});

getResult

Returns the final result of this tapping action.

Available In:

Parameters

None

Returns

Relay.Calling.TapResult - Final tap result.

Examples

Start tapping audio and grab the result when it's completed.
<?php

$tap = [
'target_type' => 'rtp',
'target_addr' => '192.168.1.1',
'target_port' => 1234
];
$call->tapAsync($tap)->done(function($action) {
// .. later in the code since it's an async method
if ($action->isCompleted()) {
$result = $action->getResult();
}
});

getPayload

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

Available In:

Parameters

None

Returns

Object - Payload sent to Relay.

Examples

Start tapping audio and print out the payload.
<?php

$tap = [
'target_type' => 'rtp',
'target_addr' => '192.168.1.1',
'target_port' => 1234
];
$call->tapAsync($tap)->done(function($action) {
print_r($action->getPayload());
});

getState

Return the current tapping state.

Available In:

Parameters

None

Returns

string - The current state.

Examples

Start tapping audio and print the state.
<?php

$tap = [ 'type' => 'audio' ];
$device = [ 'type' => 'rtp', 'addr' => '192.168.1.1', 'port' => 1234 ];
$call->tapAsync($tap, $device)->done(function($action) {
echo $action->getState();
});

isCompleted

Return true if tapping has finished, false otherwise.

Available In:

Parameters

None

Returns

Boolean - True/False accordingly to the state.

Examples

Start tapping audio and check if it has finished.
<?php

$tap = [
'target_type' => 'rtp',
'target_addr' => '192.168.1.1',
'target_port' => 1234
];
$call->tapAsync($tap)->done(function($action) {
if ($action->isCompleted()) {

}
});

getSourceDevice

Return the source device sending media.

Available In:

Parameters

None

Returns

Object - The source device.

Examples

Start tapping audio and then inspect the source device.
<?php

$tap = [
'target_type' => 'rtp',
'target_addr' => '192.168.1.1',
'target_port' => 1234
];
$call->tapAsync($tap)->done(function($action) {
$source = $action->getSourceDevice();
});

stop

Stop the action immediately.

Available In:

Parameters

None

Returns

React\Promise\Promise - Promise object that will be fulfilled with a Relay.Calling.StopResult object.

Examples

Start tapping audio and then stop the action.
<?php

$tap = [
'target_type' => 'rtp',
'target_addr' => '192.168.1.1',
'target_port' => 1234
];
$call->tapAsync($tap)->done(function($action) {
// For demonstration purposes only..
$action->stop()->done(function($stopResult) {

});
});