DetectAction
Relay.Calling.DetectAction
This object returned from one of asynchronous detect methods that represents a running detector on the call.
Methods-submenu
GetResult
Returns the final detector result.
Parameters
None
Returns
DetectResult
Relay.Calling.DetectResult
- Final detector result.
Examples
Trying detecting DTMF and grab the result when it's completed.
var det signalwire.DetectMachineParams
detectMachineAction, err := resultDial.Call.DetectMachineAsync(&det)
if err != nil {
signalwire.Log.Error("Error occurred while trying to start answering machine detector")
}
time.Sleep(15 * time.Second)
if !detectMachineAction.GetCompleted() {
detectMachineAction.Stop()
}
for {
time.Sleep(1 * time.Second)
if detectMachineAction.GetCompleted() {
signalwire.Log.Info("Machine Detection Successful(%v)\n", detectMachineAction.GetSuccessful())
break
}
signalwire.Log.Info("Last Machine event: %s Result: %v\n", detectMachineAction.GetDetectorEvent().String(), detectMachineAction.GetResult())
}
GetCompleted
Return true
if detector has finished, false
otherwise.
Parameters
None
Returns
Boolean
- True/False accordingly to the state.
Examples
Trying detecting DTMF and check if it has finished.
var det signalwire.DetectMachineParams
detectMachineAction, err := resultDial.Call.DetectMachineAsync(&det)
if err != nil {
signalwire.Log.Error("Error occurred while trying to start answering machine detector")
}
if !detectMachineAction.GetCompleted() {
detectMachineAction.Stop()
}
Stop
Stop the action immediately.
Parameters
None
Returns
StopResult
Examples
Trying detecting a machine and then stop the action.
var det signalwire.DetectMachineParams
detectMachineAction, err := resultDial.Call.DetectMachineAsync(&det)
if err != nil {
signalwire.Log.Error("Error occurred while trying to start answering machine detector")
}
detectMachineAction.Stop()
GetControlID
Return the UUID to identify the action.
Parameters
None
Returns
string
- UUID to identify the action.
Examples
Start a detector and print the controlId.
var det signalwire.DetectMachineParams
detectMachineAction, err := resultDial.Call.DetectMachineAsync(&det)
if err != nil {
signalwire.Log.Error("Error occurred while trying to start answering machine detector")
}
Signalwire.Log.Info("Detector ControlID: %s\n", detectMachineAction.GetControlID())