Example #1
0
        public RecordAction RecordAsync(CallRecord record)
        {
            RecordAction action = new RecordAction
            {
                Call      = this,
                ControlID = Guid.NewGuid().ToString(),
                Payload   = record,
            };

            Task.Run(async() =>
            {
                RecordStateChangeCallback recordStateChangeCallback = (a, c, e, p) => action.State = p.State;
                OnRecordStateChange += recordStateChangeCallback;

                action.Result    = await InternalRecordAsync(action.ControlID, record);
                action.Completed = true;

                OnRecordStateChange -= recordStateChangeCallback;
            });
            return(action);
        }
Example #2
0
        public async Task <RecordAction> RecordAsync(CallRecord record)
        {
            // Create the action first so it can hook events and not potentially miss anything
            RecordAction action = new RecordAction(this, Guid.NewGuid().ToString(), record);

            Task <CallRecordResult> taskCallRecordResult = mAPI.LL_CallRecordAsync(new CallRecordParams()
            {
                NodeID    = mNodeID,
                CallID    = mCallID,
                ControlID = action.ControlID,
                Record    = record
            });

            // The use of await ensures that exceptions are rethrown, or OperationCancelledException is thrown
            CallRecordResult callRecordResult = await taskCallRecordResult;

            // If there was an internal error of any kind then throw an exception
            mAPI.ThrowIfError(callRecordResult.Code, callRecordResult.Message);

            return(action);
        }