protected override async ValueTask <IActivityExecutionResult> OnExecuteAsync(ActivityExecutionContext context) { var callControlIdA = context.GetCallControlId(CallControlIdA); var request = new BridgeCallsRequest( CallControlIdB, ClientState, CommandId, ParkAfterUnbridged ); try { await _telnyxClient.Calls.BridgeCallsAsync(callControlIdA, request, context.CancellationToken); return(Done()); } catch (ApiException e) { if (await e.CallIsNoLongerActiveAsync()) { return(Outcome(TelnyxOutcomeNames.CallIsNoLongerActive)); } throw new WorkflowException(e.Content ?? e.Message, e); } }
protected override async ValueTask <IActivityExecutionResult> OnExecuteAsync(ActivityExecutionContext context) { CallBridgedPayloadA = null; CallBridgedPayloadB = null; var callControlIdA = CallControlIdA = context.GetCallControlId(CallControlIdA); var callControlIdB = CallControlIdB = await GetCallControlBAsync(context); if (callControlIdB == null) { throw new WorkflowException("Cannot bridge calls because the second leg's call control ID was not specified and no incoming activities provided this value"); } CallControlIdA = callControlIdA; var request = new BridgeCallsRequest( callControlIdB, ClientState, CommandId, ParkAfterUnbridged ); try { await _telnyxClient.Calls.BridgeCallsAsync(callControlIdA, request, context.CancellationToken); return(Combine(Outcome(TelnyxOutcomeNames.Bridging), Suspend())); } catch (ApiException e) { if (await e.CallIsNoLongerActiveAsync()) { return(Outcome(TelnyxOutcomeNames.CallIsNoLongerActive)); } throw new WorkflowException(e.Content ?? e.Message, e); } }