public virtual void RegisterEventHandlersForTerminal(ITerminal terminal) { terminal.OutgoingCall += (sender, arg) => { State = PortState.Busy; OutgoingCall?.Invoke(this, arg); Console.WriteLine(arg.SourceNumber + " is calling " + arg.TargetNumber); }; terminal.IncomingCall += (sender, arg) => { State = PortState.Busy; terminal.CallEventArgs = arg; Console.WriteLine(arg.SourceNumber + " is calling " + arg.TargetNumber); }; terminal.Answer += (sender, arg) => { Console.WriteLine(arg.TargetNumber + " answered " + arg.SourceNumber); Answer?.Invoke(this, arg); }; terminal.Drop += (sender, arg) => { State = PortState.Free; Drop?.Invoke(this, arg); }; this.IncomingCall += (sender, arg) => { terminal.IncomingCallFromPort(arg); }; }
async void Device_IncomingConnectionArrived(object sender, IncomingConnectionEventArgs e) { e.Accept(); await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, (() => { OutgoingCall.Visibility = Visibility.Collapsed; OutgoingCall.Stop(); RemoteVideo.Visibility = Visibility.Visible; })); await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, (() => { activated = true; var remoteAddress = e.RemoteUrl; btnEndConsult.IsEnabled = true; Interlocked.Exchange(ref isTerminator, 0); if (!((bool)roleIsActive)) { // Passive client RemoteVideo.Source = new Uri(remoteAddress); device = new CaptureDevice(); HostNameTextbox.IsEnabled = btnInitConsult.IsEnabled = false; } remoteAddress = remoteAddress.Replace("stsp://", ""); })); }
private object CreateBody(OutgoingCall outgoingCall, ContextDto context, IEventDto evt) { switch (outgoingCall.Type) { case OutgoingCallType.Vanilla: return(null); case OutgoingCallType.EventRaiser: return(new EventHandlerDto() { CorrelationId = evt.CorrelationId, Uri = $"http://{UriInfo.ServiceName}/{UriInfo.Routes.Event}" }); case OutgoingCallType.AtlasDeliveryService: return(new InitiatingEventDto() { EventId = Guid.NewGuid(), EventType = outgoingCall.TransformEventType(evt.EventType), CorrelationId = evt.CorrelationId, TimestampUtc = evt.TimestampUtc, AppTenantId = context.AppTenantId, StoreTenantId = context.StoreTenantId, ApplicationId = context.ApplicationId }); default: throw new Exception($"Unhandled {nameof(OutgoingCallType)}."); } }
private async Task <DialogTurnResult> ExecuteCallAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { try { var state = await PhoneStateAccessor.GetAsync(stepContext.Context, cancellationToken : cancellationToken); await contactFilter.FilterAsync(state, contactProvider : null); var templateId = OutgoingCallResponses.ExecuteCall; var tokens = new Dictionary <string, object>(); var outgoingCall = new OutgoingCall { Number = state.PhoneNumber, }; if (state.ContactResult.Matches.Count == 1) { tokens["contactOrPhoneNumber"] = state.ContactResult.Matches[0].Name; outgoingCall.Contact = state.ContactResult.Matches[0]; } else { tokens["contactOrPhoneNumber"] = state.PhoneNumber; } if (state.ContactResult.RequestedPhoneNumberType.Any() && state.ContactResult.Matches.Count == 1 && state.ContactResult.Matches[0].PhoneNumbers.Count == 1) { templateId = OutgoingCallResponses.ExecuteCallWithPhoneNumberType; tokens["phoneNumberType"] = GetSpeakablePhoneNumberType(state.ContactResult.Matches[0].PhoneNumbers[0].Type); } var response = TemplateManager.GenerateActivity(templateId, tokens); await stepContext.Context.SendActivityAsync(response, cancellationToken); await SendEventAsync(stepContext, outgoingCall, cancellationToken); ActionResult actionResult = null; if (state.IsAction) { actionResult = new ActionResult() { ActionSuccess = true }; } state.Clear(); return(await stepContext.EndDialogAsync(actionResult, cancellationToken)); } catch (Exception ex) { await HandleDialogExceptionsAsync(stepContext, ex, cancellationToken); return(new DialogTurnResult(DialogTurnStatus.Cancelled, CommonUtil.DialogTurnResultCancelAllDialogs)); } }
/// <summary> /// Send an event activity to communicate to the client which phone number to call. /// This event is meant to be processed by client code rather than shown to the user. /// </summary> /// <param name="stepContext">The WaterfallStepContext.</param> /// <param name="outgoingCall">The phone call to make.</param> /// <returns>A Task.</returns> private async Task SendEventAsync(WaterfallStepContext stepContext, OutgoingCall outgoingCall, CancellationToken cancellationToken) { var actionEvent = stepContext.Context.Activity.CreateReply(); actionEvent.Type = ActivityTypes.Event; actionEvent.Name = "PhoneSkill.OutgoingCall"; actionEvent.Value = outgoingCall; await stepContext.Context.SendActivityAsync(actionEvent, cancellationToken); }
protected Action <IActivity> OutgoingCallEvent(OutgoingCall expectedCall) { return(activity => { Assert.AreEqual("event", activity.Type); var eventReceived = activity.AsEventActivity(); Assert.AreEqual("PhoneSkill.OutgoingCall", eventReceived.Name); Assert.IsInstanceOfType(eventReceived.Value, typeof(OutgoingCall)); Assert.AreEqual(expectedCall, (OutgoingCall)eventReceived.Value); }); }
/* * Disconnect an active Call */ private void disconnect() { if (activeOutgoingCall != null) { activeOutgoingCall.disconnect(); activeOutgoingCall = null; } else if (activeIncomingCall != null) { activeIncomingCall.reject(); activeIncomingCall = null; } }
public string OutgoingCall(IList <string> arguments) { string name = arguments[1]; string callingToNumber = arguments[2]; var currentUser = dbContext.Users.FirstOrDefault(a => a.Name == name); if (currentUser != null) { var outgoingCall = new OutgoingCall { PhoneUserId = currentUser.Id, OutgoingNumber = callingToNumber }; currentUser.OutgoingCalls.Add(outgoingCall); dbContext.OutgoingCalls.Add(outgoingCall); dbContext.SaveChanges(); return($"Calling {callingToNumber} ..."); } return("There is no such name!"); }
private async void InitiateConsultation() { try { if (HostNameTextbox.Text != "") { var address = HostNameTextbox.Text;//VideoVM!=null&&!string.IsNullOrEmpty(VideoVM.IpAddress)?VideoVM.IpAddress:string.Empty; roleIsActive = true; RemoteVideo.Source = new Uri("stsp://" + address); HostNameTextbox.IsEnabled = btnInitConsult.IsEnabled = false; RemoteVideo.Visibility = Visibility.Collapsed; OutgoingCall.Visibility = Visibility.Visible; OutgoingCall.Play(); btnEndConsult.Visibility = Visibility.Visible; btnInitConsult.Visibility = Visibility.Collapsed; HostNameTextbox.Visibility = Visibility.Collapsed; } } catch (Exception) { throw; } }
public override void onDisconnected(OutgoingCall outgoingCall, CallException error) { outerInstance.resetUI(); Log.e(TAG, string.Format("Error: {0:D}, {1}", error.ErrorCode, error.Message)); }
public override void onDisconnected(OutgoingCall outgoingCall) { outerInstance.resetUI(); Log.d(TAG, "Disconnect"); }
public override void onConnected(OutgoingCall outgoingCall) { Log.d(TAG, "Connected"); }
protected virtual void OnOutgoingCall(object sender, CallEventArgs args) { OutgoingCall?.Invoke(sender, args); }
private void OnOutgoingCall(CallData callData) { OutgoingCall?.Invoke(this, callData); }
public void Read(OutgoingCall call) { AddToDb(call, false); }
protected virtual void OnOnutgoingCall(object sender, IPhoneNumber number) { OutgoingCall?.Invoke(sender, number); }