private static void CallingAPI_OnCallReceived(CallingAPI api, Call call, CallEventParams.ReceiveParams receiveParams) { Logger.LogInformation("OnCallReceived: {0}, {1}", call.CallID, call.State); Task.Run(() => { try { call.Answer(); } catch (Exception exc) { Logger.LogError(exc, "Answer failed"); sCompleted.Set(); return; } try { call.OnPlayStateChange += OnCallPlayStateChange; call.PlayTTS( new CallMedia.TTSParams() { Text = "i'm a little teapot", }); } catch (Exception exc) { Logger.LogError(exc, "PlayTTS failed"); sCompleted.Set(); return; } }); }
private static void OnCallRecordStateChange(CallingAPI api, Call call, CallEventParams.RecordParams recordParams) { Logger.LogInformation("OnCallRecordStateChange: {0}, {1} for {2}, {3}", call.CallID, call.State, recordParams.ControlID, recordParams.State); if (recordParams.State == CallEventParams.RecordParams.RecordState.finished || recordParams.State == CallEventParams.RecordParams.RecordState.no_input) { Logger.LogInformation("OnCallRecordStateChange: {0}, {1}, {2}", recordParams.Duration, recordParams.Size, recordParams.URL); sSuccessful = true; sCompleted.Set(); } }
private static void OnCallPlayStateChange(CallingAPI api, Call call, CallEventParams.PlayParams playParams) { Logger.LogInformation("OnCallPlayStateChange: {0}, {1} for {2}, {3}", call.CallID, call.State, playParams.ControlID, playParams.State); if (playParams.State == CallEventParams.PlayParams.PlayState.finished) { Logger.LogInformation("OnCallPlayStateChange completed successfully"); sSuccessful = true; sCompleted.Set(); } }
private static void CallingAPI_OnCallReceived(CallingAPI api, Call call, CallEventParams.ReceiveParams receiveParams) { Logger.LogInformation("OnCallReceived: {0}, {1}", call.CallID, call.State); Task.Run(() => { try { call.Answer(); } catch (Exception exc) { Logger.LogError(exc, "Answer failed"); sCompleted.Set(); return; } Thread.Sleep(1000); try { call.OnCollect += OnCallCollect; PlayTTSAndCollectAction action = call.PlayTTSAndCollect( new CallMedia.TTSParams() { Text = "i'm a little teapot, short and stout. Here is my handle, here is my spout.", }, new CallCollect() { Digits = new CallCollect.DigitsParams() { Max = 1 } }); Thread.Sleep(2000); action.Stop(); call.PlayTTS(new CallMedia.TTSParams() { Text = "Stopped" }); Thread.Sleep(1000); call.Hangup(); sSuccessful = true; sCompleted.Set(); } catch (Exception exc) { Logger.LogError(exc, "PlayTTSAndCollect failed"); sCompleted.Set(); return; } }); }
private void Call_OnPlayStateChange(CallingAPI api, Call call, CallEventParams.PlayParams playParams) { switch (playParams.State) { case CallEventParams.PlayParams.PlayState.error: case CallEventParams.PlayParams.PlayState.finished: Call.OnPlayStateChange -= Call_OnPlayStateChange; mFinished.SetResult(true); break; default: break; } }
private void Call_OnRecordStateChange(CallingAPI api, Call call, CallEventParams.RecordParams recordParams) { switch (recordParams.State) { case CallEventParams.RecordParams.RecordState.finished: case CallEventParams.RecordParams.RecordState.no_input: Call.OnRecordStateChange -= Call_OnRecordStateChange; mFinished.SetResult(true); break; default: break; } }
private static void CallingAPI_OnCallReceived(CallingAPI api, Call call, CallEventParams.ReceiveParams receiveParams) { Logger.LogInformation("OnCallReceived: {0}, {1}", call.CallID, call.State); Task.Run(() => { try { call.Answer(); } catch (Exception exc) { Logger.LogError(exc, "Answer failed"); sCompleted.Set(); } }); }
private static void CallingAPI_OnCallReceived(CallingAPI api, Call call, CallEventParams.ReceiveParams receiveParams) { // This is called when the client is informed that a new inbound call has been created Logger.LogInformation("OnCallReceived: {0}, {1}", call.CallID, call.State); // Answer the inbound call try { call.Answer(); } catch (Exception exc) { Logger.LogError(exc, "CallAnswer failed"); return; } Call callB = null; try { // The top level list of the devices represents entries that will be called in serial, // one at a time. The inner list of devices represents a set of devices to call in // parallel with each other. Ultimately only one device wins by answering first. callB = call.Connect(new List <List <CallDevice> > { new List <CallDevice> { new CallDevice { Type = CallDevice.DeviceType.phone, Parameters = new CallDevice.PhoneParams { ToNumber = sCallToNumber, FromNumber = sCallFromNumber, } } } }); } catch (Exception exc) { Logger.LogError(exc, "Connect failed"); return; } // Wait upto 15 seconds for the connected side to end then hangup callB.WaitForState(TimeSpan.FromSeconds(15), CallState.ended); call.Hangup(); }
private static void Client_OnReady(Client client) { // This is called when the client has established a new session, this is NOT called when a session is restored Logger.LogInformation("OnReady"); // Create the api associating it to the client for transport sCallingAPI = new CallingAPI(client); // Hook the callback that occurs when an inbound call is created sCallingAPI.OnCallReceived += CallingAPI_OnCallReceived; // Request that the inbound calls for the given context reach this client try { sCallingAPI.Receive(sCallReceiveContext); } catch (Exception exc) { Logger.LogError(exc, "CallReceive failed"); return; } }
private static void OnCallCollect(CallingAPI api, Call call, CallEventParams.CollectParams collectParams) { Logger.LogInformation("OnCallCollectResult: {0}, {1} for {2}, {3}", call.CallID, call.State, collectParams.ControlID, collectParams.Result.Type); }
private static void CallingAPI_OnCallCreated(CallingAPI api, Call call) { Logger.LogInformation("OnCallCreated: {0}, {1}", call.CallID, call.State); }
private static void Client_OnReady(Client client) { // This is called when the client has established a new session, this is NOT called when a session is restored Logger.LogInformation("OnReady"); // Create the api associating it to the client for transport sCallingAPI = client.Calling; Task.Run(() => { CallSetup( "Human", sCallToHumanNumber, sRunHuman, sHumanCompleted, OnCallDetectHuman, () => sHumanSuccessful = true, new CallDetect() { Type = CallDetect.DetectType.machine, Parameters = new CallDetect.MachineParams() { }, }); CallSetup( "Machine", sCallToMachineNumber, sRunMachine, sMachineCompleted, OnCallDetectMachine, () => sMachineSuccessful = true, new CallDetect() { Type = CallDetect.DetectType.machine, Parameters = new CallDetect.MachineParams() { }, }); CallSetup( "Fax", sCallToFaxNumber, sRunFax, sFaxCompleted, OnCallDetectFax, () => sFaxSuccessful = true, new CallDetect() { Type = CallDetect.DetectType.fax, Parameters = new CallDetect.FaxParams() { }, }); CallSetup( "Digit", sCallToDigitNumber, sRunDigit, sDigitCompleted, OnCallDetectDigit, () => sDigitSuccessful = true, new CallDetect() { Type = CallDetect.DetectType.digit, Parameters = new CallDetect.DigitParams() { }, }); }); }
internal PhoneCall(CallingAPI api, string temporaryCallID) : base(api, temporaryCallID) { }
internal PhoneCall(CallingAPI api, string nodeID, string callID) : base(api, nodeID, callID) { }
protected Call(CallingAPI api, string temporaryCallID) { mLogger = SignalWireLogging.CreateLogger <Client>(); mAPI = api; mTemporaryID = temporaryCallID; }
private void Call_OnCollect(CallingAPI api, Call call, CallEventParams.CollectParams collectParams) { Call.OnCollect -= Call_OnCollect; mFinished.SetResult(true); }