Пример #1
0
 public static Task DrainAsync(this
                               ApplicationEndpoint endpoint)
 {
     return(Task.Factory.FromAsync(
                endpoint.BeginDrain,
                endpoint.EndDrain, null));
 }
Пример #2
0
 private void StartupEndpoint(AsyncTask task, object state)
 {
     task.DoOneStep(
         delegate()
     {
         m_endpoint = new ApplicationEndpoint(m_parent.Platform, m_settings);
         m_endpoint.RegisterForIncomingCall <AudioVideoCall>(this.ReceiveIncomingAvCall);
         m_endpoint.RegisterForIncomingCall <InstantMessagingCall>(this.ReceiveIncomingIMCall);
         m_endpoint.LocalOwnerPresence.SubscriberNotificationReceived += SubscriberNotificationReceived;
         m_endpoint.StateChanged += this.EndpointStateChanged;
         Logger.Log(Logger.LogLevel.Info, "Starting Application Endpoint.");
         m_endpoint.BeginEstablish(
             delegate(IAsyncResult ar)
         {
             task.DoOneStep(
                 delegate()
             {
                 m_endpoint.EndEstablish(ar);
                 Logger.Log(Logger.LogLevel.Info, "Started Application Endpoint. Tel #:" + m_endpoint.OwnerPhoneUri ?? "null");
                 m_endpoint.LocalOwnerPresence.BeginSubscribe(
                     delegate(IAsyncResult ar2)
                 {
                     task.DoFinalStep(
                         delegate()
                     {
                         m_endpoint.LocalOwnerPresence.EndSubscribe(ar2);
                     });
                 },
                     null);
             });
         },
             null);
     });
 }
Пример #3
0
        public async Task ShouldRaiseIncomingAudioVideoInviteToAllRegisteredEventHandlersInOrder()
        {
            var loggingContext = new LoggingContext(Guid.NewGuid());
            var data           = TestHelper.CreateApplicationEndpoint();
            Mock <IEventChannel> mockEventChannel    = data.EventChannel;
            ApplicationEndpoint  applicationEndpoint = data.ApplicationEndpoint;

            await applicationEndpoint.InitializeAsync(loggingContext).ConfigureAwait(false);

            await applicationEndpoint.InitializeApplicationAsync(loggingContext).ConfigureAwait(false);

            // Given
            var eventsReceived = 0;
            var lastEvent      = 0;

            applicationEndpoint.HandleIncomingAudioVideoCall += (sender, args) => { ++eventsReceived; lastEvent = 1; };
            applicationEndpoint.HandleIncomingAudioVideoCall += (sender, args) => { ++eventsReceived; lastEvent = 2; };

            // When
            TestHelper.RaiseEventsFromFile(mockEventChannel, "Event_IncomingAudioCall.json");

            // Then
            Assert.AreEqual(2, eventsReceived);
            Assert.AreEqual(2, lastEvent);
        }
Пример #4
0
        public void ApplicationEndpointSubscribesToEventChannelBeforeStartingIt()
        {
            // Given
            var loggingContext      = new LoggingContext(Guid.NewGuid());
            var callbackHttpRequest = TestHelper.GetEventsChannelArgs("Event_Empty.json").CallbackHttpRequest;
            var data = TestHelper.CreateApplicationEndpoint();

            // We don't have a clean way of checking if the event is consumed by ApplicationEndpoint.
            // In this hacky way we raise an event with mock event args, if someone reads the CallbackHttpRequest
            // property, we can be sure that the event was consumed.
            var propertyAccessed = false;
            var mockEventArgs    = new Mock <EventsChannelArgs>(callbackHttpRequest);

            mockEventArgs
            .Setup(mock => mock.CallbackHttpRequest)
            .Returns(callbackHttpRequest)
            .Callback(() => propertyAccessed = true);

            // When
            ApplicationEndpoint  applicationEndpoint = data.ApplicationEndpoint;
            Mock <IEventChannel> mockEventChannel    = data.EventChannel;

            mockEventChannel.Raise(mock => mock.HandleIncomingEvents += null, mockEventChannel.Object, mockEventArgs.Object);

            // Then
            mockEventChannel.Verify(foo => foo.TryStartAsync(), Times.Never);
            Assert.IsTrue(propertyAccessed, "Event was not consumed by ApplicationEndpoint. This indicates that event handler was not registered.");
        }
Пример #5
0
 /// <summary>
 /// Constructs a new web conversation manager.
 /// </summary>
 /// <param name="applicationEndpoint">Application endpoint to use.</param>
 internal WebConversationManager(ApplicationEndpoint applicationEndpoint, TimerWheel timerWheel)
 {
     Debug.Assert(null != applicationEndpoint, "Application endpoint cannot be null");
     m_applicationEndpoint   = applicationEndpoint;
     m_webConversationPoller = new WebConversationPoller(this, timerWheel);
     m_webConversationPoller.Start();
 }
Пример #6
0
        public async Task ShoulNotRaiseIncomingAudioVideoInvitationToUnregisteredHandler()
        {
            // Given
            var loggingContext = new LoggingContext(Guid.NewGuid());
            var data           = TestHelper.CreateApplicationEndpoint();
            Mock <IEventChannel> mockEventChannel    = data.EventChannel;
            ApplicationEndpoint  applicationEndpoint = data.ApplicationEndpoint;
            var callReceived = false;

            await applicationEndpoint.InitializeAsync(loggingContext).ConfigureAwait(false);

            await applicationEndpoint.InitializeApplicationAsync(loggingContext).ConfigureAwait(false);

            EventHandler <IncomingInviteEventArgs <IAudioVideoInvitation> > handler = (sender, args) => { callReceived = true; };

            applicationEndpoint.HandleIncomingAudioVideoCall += handler;

            TestHelper.RaiseEventsFromFile(mockEventChannel, "Event_IncomingAudioCall.json");
            Assert.IsTrue(callReceived, "AudioVideo call not raised by SDK.");
            callReceived = false;

            // When
            applicationEndpoint.HandleIncomingAudioVideoCall -= handler;

            // Then
            Assert.IsFalse(callReceived, "AudioVideo call raised by SDK to an unregistered event handler.");
        }
Пример #7
0
 /// <summary>
 /// Initialize a new instance of OutBoundInstantMessagingCall.
 /// Throws ArgumentNullException if appEndPoint or conversationSettings or destinationUri is null
 /// </summary>
 /// <param name="appEndPoint"></param>
 /// <param name="csettings"></param>
 /// <param name="destinationUri"></param>
 public OutBoundInstantMessagingCall(ApplicationEndpoint appEndPoint, ConversationSettings csettings, string destinationUri)
     : this()
 {
     this.AppEndPoint    = appEndPoint;
     this.ConvSettings   = csettings;
     this.DestinationUri = destinationUri;
 }
            internal static ApplicationEndpoint GetTlsEndPoint(int listeningPort, string certificateThumbprint)
            {
                BaseUMconnectivityTester.SipPlatformConnectionManager.DebugTrace("Inside ConnectionManager GetTlsEndpoint().", new object[0]);
                ApplicationEndpoint applicationEndpoint = null;
                X509Certificate2    cert = BaseUMconnectivityTester.SipPlatformConnectionManager.GetCert(certificateThumbprint);
                string key = string.Format(CultureInfo.InvariantCulture, "{0}:{1}", new object[]
                {
                    cert.Thumbprint,
                    listeningPort
                });

                lock (BaseUMconnectivityTester.SipPlatformConnectionManager.syncLock)
                {
                    if (BaseUMconnectivityTester.SipPlatformConnectionManager.tlsEndPoints == null)
                    {
                        BaseUMconnectivityTester.SipPlatformConnectionManager.tlsEndPoints = new Dictionary <string, ApplicationEndpoint>(StringComparer.OrdinalIgnoreCase);
                    }
                    if (!BaseUMconnectivityTester.SipPlatformConnectionManager.tlsEndPoints.TryGetValue(key, out applicationEndpoint))
                    {
                        applicationEndpoint = BaseUMconnectivityTester.SipPlatformConnectionManager.CreateEndPoint(new ServerPlatformSettings("MSExchangeUM-Diagnostics", Utils.GetOwnerHostFqdn(), listeningPort, null, cert)
                        {
                            OutboundConnectionConfiguration =
                            {
                                DefaultAddressFamilyHint = new AddressFamilyHint?(0)
                            }
                        });
                        BaseUMconnectivityTester.SipPlatformConnectionManager.tlsEndPoints.Add(key, applicationEndpoint);
                    }
                }
                BaseUMconnectivityTester.SipPlatformConnectionManager.DebugTrace("Returning from GetTLSEndPoint.", new object[0]);
                return(applicationEndpoint);
            }
Пример #9
0
        public async void TestSetup()
        {
            m_loggingContext = new LoggingContext(Guid.NewGuid());
            var data = TestHelper.CreateApplicationEndpoint();

            m_mockEventChannel = data.EventChannel;
            m_restfulClient    = data.RestfulClient;

            ApplicationEndpoint applicationEndpoint = data.ApplicationEndpoint;
            await applicationEndpoint.InitializeAsync(m_loggingContext).ConfigureAwait(false);

            await applicationEndpoint.InitializeApplicationAsync(m_loggingContext).ConfigureAwait(false);

            IConversation conversation = null;

            applicationEndpoint.HandleIncomingAudioVideoCall += (sender, args) => conversation = args.NewInvite.RelatedConversation;

            TestHelper.RaiseEventsFromFile(m_mockEventChannel, "Event_IncomingAudioCall.json");
            TestHelper.RaiseEventsFromFile(m_mockEventChannel, "Event_ConversationConnected_WithAudio.json");
            TestHelper.RaiseEventsFromFile(m_mockEventChannel, "Event_AudioVideoConnected.json");

            m_restfulClient.HandleRequestProcessed     +=
                (sender, args) => m_transferOperationId = TestHelper.RaiseEventsOnHttpRequest(args, DataUrls.Transfer, HttpMethod.Post, "Event_TransferStarted.json", m_mockEventChannel);

            m_transfer = await conversation.AudioVideoCall.TransferAsync(new SipUri("sip:[email protected]"), null, m_loggingContext).ConfigureAwait(false);
        }
Пример #10
0
        // Registered event handler for the ApplicationEndpointOwnerDiscovered event on the
        // CollaborationPlatform for the provisioned application.
        private void Platform_ApplicationEndpointOwnerDiscovered(object sender,
                                                                 ApplicationEndpointSettingsDiscoveredEventArgs e)
        {
            Helper.Logger.Info("ApplicationEndpointOwnerDiscovered event was raised during startup of the "
                               + "CollaborationPlatform.");

            ApplicationEndpointSettings settings = e.ApplicationEndpointSettings;

            settings.UseRegistration = false;

            m_applicationEndpoint = new ApplicationEndpoint(m_collabPlatform, settings);

            bool epBeginEstablishFailed = true;

            try
            {
                this.RegisterEndpointEventHandlers(m_applicationEndpoint);
                m_applicationEndpoint.BeginEstablish(this.EndpointEstablishCompleted, m_applicationEndpoint);
                epBeginEstablishFailed = false;
            }
            catch (InvalidOperationException ioe)
            {
                Helper.Logger.Error("Endpoint establishment operation threw an exception {0}", EventLogger.ToString(ioe));
            }
            finally
            {
                if (epBeginEstablishFailed)
                {
                    this.Cleanup();
                }
            }
        }
Пример #11
0
        public async void TestSetup()
        {
            m_loggingContext = new LoggingContext(Guid.NewGuid());
            var data = TestHelper.CreateApplicationEndpoint();

            m_mockEventChannel = data.EventChannel;
            m_restfulClient    = data.RestfulClient;

            m_applicationEndpoint = data.ApplicationEndpoint;
            await m_applicationEndpoint.InitializeAsync(m_loggingContext).ConfigureAwait(false);

            await m_applicationEndpoint.InitializeApplicationAsync(m_loggingContext).ConfigureAwait(false);

            ICommunication communication = m_applicationEndpoint.Application.Communication;

            m_restfulClient.HandleRequestProcessed += (sender, args) =>
            {
                TestHelper.RaiseEventsOnHttpRequest(args, DataUrls.MessagingInvitations, HttpMethod.Post, "Event_MessagingInvitationStarted.json", m_mockEventChannel);
                TestHelper.RaiseEventsOnHttpRequest(args, DataUrls.EstablishMessagingCall, HttpMethod.Post, "Event_MessagingInvitationStarted.json", m_mockEventChannel);
            };

            // Start a messaging invitation
            m_messagingInvitation = await communication.StartMessagingWithIdentityAsync(
                "Test subject",
                "sip:[email protected]",
                "https://example.com/callback",
                "Local user",
                "sip:[email protected]",
                m_loggingContext).ConfigureAwait(false);
        }
Пример #12
0
        public async Task ShouldRaiseIncomingIMInviteOnceIfSameEventHandlerRegisteredMultipleTimes()
        {
            var loggingContext = new LoggingContext(Guid.NewGuid());
            var data           = TestHelper.CreateApplicationEndpoint();
            Mock <IEventChannel> mockEventChannel    = data.EventChannel;
            ApplicationEndpoint  applicationEndpoint = data.ApplicationEndpoint;

            await applicationEndpoint.InitializeAsync(loggingContext).ConfigureAwait(false);

            await applicationEndpoint.InitializeApplicationAsync(loggingContext).ConfigureAwait(false);


            // Given
            var eventsReceived = 0;
            EventHandler <IncomingInviteEventArgs <IMessagingInvitation> > handler = (sender, args) => { Interlocked.Increment(ref eventsReceived); };

            applicationEndpoint.HandleIncomingInstantMessagingCall += handler;
            applicationEndpoint.HandleIncomingInstantMessagingCall += handler;

            // When
            TestHelper.RaiseEventsFromFile(mockEventChannel, "Event_IncomingIMCall.json");

            // Then
            Assert.AreEqual(1, eventsReceived);
        }
Пример #13
0
        public async Task RunAsync()
        {
            var skypeId         = ConfigurationManager.AppSettings["Trouter_SkypeId"];
            var password        = ConfigurationManager.AppSettings["Trouter_Password"];
            var applicationName = ConfigurationManager.AppSettings["Trouter_ApplicationName"];
            var userAgent       = ConfigurationManager.AppSettings["Trouter_UserAgent"];
            var token           = SkypeTokenClient.ConstructSkypeToken(
                skypeId: skypeId,
                password: password,
                useTestEnvironment: false,
                scope: string.Empty,
                applicationName: applicationName).Result;

            m_logger = new ConsoleLogger();

            // Uncomment for debugging
            // m_logger.HttpRequestResponseNeedsToBeLogged = true;

            EventChannel = new TrouterBasedEventChannel(m_logger, token, userAgent);

            // Prepare platform
            var platformSettings = new ClientPlatformSettings(QuickSamplesConfig.AAD_ClientSecret, new Guid(QuickSamplesConfig.AAD_ClientId));
            var platform         = new ClientPlatform(platformSettings, m_logger);

            // Prepare endpoint
            var endpointSettings    = new ApplicationEndpointSettings(new SipUri(QuickSamplesConfig.ApplicationEndpointId));
            var applicationEndpoint = new ApplicationEndpoint(platform, endpointSettings, EventChannel);

            var loggingContext = new LoggingContext(Guid.NewGuid());
            await applicationEndpoint.InitializeAsync(loggingContext).ConfigureAwait(false);

            await applicationEndpoint.InitializeApplicationAsync(loggingContext).ConfigureAwait(false);

            // Meeting configuration
            var meetingConfiguration = new AdhocMeetingCreationInput(Guid.NewGuid().ToString("N") + " test meeting");

            // Schedule meeting
            var adhocMeeting = await applicationEndpoint.Application.CreateAdhocMeetingAsync(loggingContext, meetingConfiguration).ConfigureAwait(false);

            WriteToConsoleInColor("ad hoc meeting uri : " + adhocMeeting.OnlineMeetingUri);
            WriteToConsoleInColor("ad hoc meeting join url : " + adhocMeeting.JoinUrl);

            // Get all the events related to join meeting through Trouter's uri
            platformSettings.SetCustomizedCallbackurl(new Uri(EventChannel.CallbackUri));

            // Start joining the meeting
            var invitation = await adhocMeeting.JoinAdhocMeeting(loggingContext, null).ConfigureAwait(false);

            // Wait for the join to complete
            await invitation.WaitForInviteCompleteAsync().ConfigureAwait(false);

            invitation.RelatedConversation.HandleParticipantChange += Conversation_HandleParticipantChange;

            WriteToConsoleInColor("Showing roaster udpates for 5 minutes for meeting : " + adhocMeeting.JoinUrl);

            // Wait 5 minutes before exiting.
            // Since we have registered Conversation_HandleParticipantChange, we will continue to show participant changes in the
            // meeting for this duration.
            await Task.Delay(TimeSpan.FromMinutes(5)).ConfigureAwait(false);
        }
Пример #14
0
        // Registered event handler for the ApplicationEndpointOwnerDiscovered
        // event on the CollaborationPlatform for the provisioned application.
        private void Platform_ApplicationEndpointOwnerDiscovered(object sender,
                                                                 ApplicationEndpointSettingsDiscoveredEventArgs e)
        {
            Console.WriteLine("ApplicationEndpointOwnerDiscovered event was raised during startup of the "
                              + "CollaborationPlatform for the provisioned application with ID \'{0}\'.");

            ApplicationEndpointSettings settings = e.ApplicationEndpointSettings;

            settings.SupportedMimePartContentTypes = new ContentType[] { new ContentType("text/plain") };

            //Set the endpoint presence to appear as always online
            InitializePublishAlwaysOnlineSettings(settings);

            Console.WriteLine("Initializing the ApplicationEndpoint that corresponds to the provisioned "
                              + "application with ID \'{0}\'.", _appID);

            // Initialize the endpoint using the settings retrieved above.
            _appEndpoint = new ApplicationEndpoint(_collabPlatform, settings);
            // Wire up the StateChanged event.
            _appEndpoint.StateChanged += this.Endpoint_StateChanged;
            try
            {
                // Establish the endpoint.
                _appEndpoint.BeginEstablish(EndEndpointEstablish, _appEndpoint);
            }
            catch (InvalidOperationException iOpEx)
            {
                // Invalid Operation Exception may be thrown if the data
                // provided to the BeginXXX methods was invalid/malformed.
                // TODO (Left to the reader): Write actual handling code for the
                // occurrence.
                Console.WriteLine("Invalid Operation Exception: " + iOpEx.ToString());
            }
        }
Пример #15
0
 /// <summary>
 /// Initialize properties from the inputParameters dictionary.
 /// </summary>
 /// <param name="inputParameters"></param>
 public override void InitializeParameters(Dictionary <string, object> inputParameters)
 {
     this.AgentUri = inputParameters["AgentUri"] as string;
     this.QaAgentOfferMainPrompt          = inputParameters["QaAgentOfferMainPrompt"] as string;
     this.QaAgentOfferNoRecognitionPrompt = inputParameters["QaAgentOfferNoRecognitionPrompt"] as string;
     this.QaAgentOfferSilencePrompt       = inputParameters["QaAgentOfferSilencePrompt"] as string;
     this.appEndPoint = inputParameters["ApplicationEndPoint"] as ApplicationEndpoint;
 }
Пример #16
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="applicationEndpoint">App endpoint.</param>
 internal UcPresenceCache(ApplicationEndpoint applicationEndpoint)
 {
     m_presenceProvider = new UcPresenceProvider(applicationEndpoint);
     m_presenceProvider.Start();
     m_presenceProvider.PresenceChanged += this.PresenceProvider_PresenceChanged;
     StaleInterval = TimeSpan.FromHours(2);
     m_staleTimer  = new Timer(OnStaleTimerTick, null, StaleInterval, TimeSpan.FromMilliseconds(-1));
 }
Пример #17
0
 public PresenceHelper(ApplicationEndpoint appEndpoint)
 {
     _appEndpoint = appEndpoint;
     
     // Subscribe to receive presence notifications
     _remotePresenceView = new RemotePresenceView(appEndpoint);
     _remotePresenceView.PresenceNotificationReceived += new EventHandler<RemotePresentitiesNotificationEventArgs>(PresenceReceivedEventHandler);
 }
Пример #18
0
        public async Task RunAsync(Uri callbackUri)
        {
            m_logger = new SampleAppLogger();

            // Uncomment for debugging
            // m_logger.HttpRequestResponseNeedsToBeLogged = true;

            // Prepare platform
            var platformSettings = new ClientPlatformSettings(QuickSamplesConfig.AAD_ClientSecret, new Guid(QuickSamplesConfig.AAD_ClientId));
            var platform         = new ClientPlatform(platformSettings, m_logger);

            // You can hook up your own implementation of IEventChannel here
            IEventChannel eventChannel = WebEventChannel.WebEventChannel.Instance;

            // Prepare endpoint
            var endpointSettings    = new ApplicationEndpointSettings(new SipUri(QuickSamplesConfig.ApplicationEndpointId));
            var applicationEndpoint = new ApplicationEndpoint(platform, endpointSettings, eventChannel);

            var loggingContext = new LoggingContext(Guid.NewGuid());
            await applicationEndpoint.InitializeAsync(loggingContext).ConfigureAwait(false);

            await applicationEndpoint.InitializeApplicationAsync(loggingContext).ConfigureAwait(false);

            // Meeting configuration
            var meetingConfiguration = new AdhocMeetingCreationInput(Guid.NewGuid().ToString("N") + " test meeting");

            // Schedule meeting
            var adhocMeeting = await applicationEndpoint.Application.CreateAdhocMeetingAsync(meetingConfiguration, loggingContext).ConfigureAwait(false);

            WriteToConsoleInColor("ad hoc meeting uri : " + adhocMeeting.OnlineMeetingUri);
            WriteToConsoleInColor("ad hoc meeting join url : " + adhocMeeting.JoinUrl);

            // Get all the events related to join meeting through our custom callback uri
            platformSettings.SetCustomizedCallbackurl(callbackUri);

            // Start joining the meeting
            ICommunication communication = applicationEndpoint.Application.Communication;

            if (!communication.CanJoinAdhocMeeting(adhocMeeting))
            {
                throw new Exception("Cannot join adhoc meeting");
            }

            var invitation = await communication.JoinAdhocMeetingAsync(adhocMeeting, null, loggingContext).ConfigureAwait(false);

            // Wait for the join to complete
            await invitation.WaitForInviteCompleteAsync().ConfigureAwait(false);

            invitation.RelatedConversation.HandleParticipantChange += Conversation_HandleParticipantChange;
            WriteToConsoleInColor("Showing roaster udpates for 5 minutes for meeting : " + adhocMeeting.JoinUrl);

            // Wait 5 minutes before exiting.
            // Since we have registered Conversation_HandleParticipantChange, we will continue to show participant changes in the
            // meeting for this duration.
            await Task.Delay(TimeSpan.FromMinutes(5)).ConfigureAwait(false);

            await WebEventChannel.WebEventChannel.Instance.TryStopAsync().ConfigureAwait(false);
        }
Пример #19
0
 /// <summary>
 /// Initialize a new instance of CommitAgentDialog.
 /// </summary>
 /// <param name="agentUri">Sip uri of agent</param>
 /// <param name="mainPrompt">Main prompt</param>
 /// <param name="noRecoPrompt">No recognition prompt</param>
 /// <param name="silencePrompt">Silence prompt</param>
 /// <param name="appEndPoint">Application endpoint</param>
 public CommitAgentDialog(string agentUri, string mainPrompt, string noRecoPrompt, string silencePrompt, ApplicationEndpoint appEndPoint)
     : this()
 {
     this.AgentUri = agentUri;
     this.QaAgentOfferMainPrompt          = mainPrompt;
     this.QaAgentOfferNoRecognitionPrompt = noRecoPrompt;
     this.QaAgentOfferSilencePrompt       = silencePrompt;
     this.appEndPoint = appEndPoint;
 }
Пример #20
0
 public CommitAgentDialog(Dictionary <string, object> inputParameters)
     : this()
 {
     this.AgentUri = inputParameters["AgentUri"] as string;
     this.QaAgentOfferMainPrompt          = inputParameters["QaAgentOfferMainPrompt"] as string;
     this.QaAgentOfferNoRecognitionPrompt = inputParameters["QaAgentOfferNoRecognitionPrompt"] as string;
     this.QaAgentOfferSilencePrompt       = inputParameters["QaAgentOfferSilencePrompt"] as string;
     this.appEndPoint = inputParameters["ApplicationEndPoint"] as ApplicationEndpoint;
 }
Пример #21
0
        /// <summary>
        /// Record the endpoint state transitions to the console.
        /// </summary>
        /// <param name="sender">Endpoint that saw its state change.</param>
        /// <param name="e">Data about the endpoint state change event.</param>
        private void _endpoint_StateChanged(object sender, LocalEndpointStateChangedEventArgs e)
        {
            // Extract the endpoint that sent the state change event.
            ApplicationEndpoint endpoint = sender as ApplicationEndpoint;

            UCMASampleHelper.WriteLine("Endpoint (" + endpoint.OwnerUri
                                       + ") has changed state. The previous endpoint state was '"
                                       + e.PreviousState + "' and the current state is '" + e.State + "'.");
        }
Пример #22
0
 private async void OnNewApplicationEndpointDiscovered(object sender, ApplicationEndpointSettingsDiscoveredEventArgs e)
 {
     log.Info(string.Format("New Endpoint {0} discovered", e.ApplicationEndpointSettings.OwnerUri));
     _endpoint = new ApplicationEndpoint(_collabPlatform, e.ApplicationEndpointSettings);
     _endpoint.RegisterForIncomingCall<InstantMessagingCall>(OnIncomingIM);
     
     await _endpoint.EstablishAsync();
     log.Info("Endpoint established");
    LyncServerReady(this, new EventArgs());
 }
Пример #23
0
 internal AcdConferenceServicesAnchor(string conferenceUri, ApplicationEndpoint endpoint, AcdLogger logger)
 {
     _endpoint      = endpoint;
     _logger        = logger;
     _conferenceUri = conferenceUri;
     _state         = ConferenceServicesAnchorState.Idle;
     _conversation  = new Conversation(endpoint);
     _conversation.Impersonate("sip:" + Guid.NewGuid() + "@" + endpoint.DefaultDomain, null, null);
     _conversation.ApplicationContext = this;
 }
Пример #24
0
        private void HandleIncomingAVCall(object sender, IncomingInviteEventArgs <IAudioVideoInvitation> args)
        {
            //Read job settings
            string callbackUri = ConfigurationManager.AppSettings["MyCallbackUri"];

            ApplicationEndpoint ae  = sender as ApplicationEndpoint;
            AudioVideoIVRJob    job = new AudioVideoIVRJob(args, callbackUri);

            job.Start();
        }
Пример #25
0
        private async void OnNewApplicationEndpointDiscovered(object sender, ApplicationEndpointSettingsDiscoveredEventArgs e)
        {
            Console.WriteLine(string.Format("New Endpoint {0} discovered", e.ApplicationEndpointSettings.OwnerUri));
            _endpoint = new ApplicationEndpoint(_collabPlatform, e.ApplicationEndpointSettings);
            _endpoint.RegisterForIncomingCall <InstantMessagingCall>(OnIncomingCall);
            await _endpoint.EstablishAsync();

            Console.WriteLine("Endpoint established");
            LyncServerReady(this, new EventArgs());
        }
 private async void OnNewApplicationEndpointDiscovered(object sender, ApplicationEndpointSettingsDiscoveredEventArgs e)
 {
     Console.WriteLine(string.Format("New Endpoint {0} discovered", e.ApplicationEndpointSettings.OwnerUri));
     _endpoint = new ApplicationEndpoint(_collabPlatform, e.ApplicationEndpointSettings);
     _endpoint.RegisterForIncomingCall<AudioVideoCall>(OnIncomingCall);
     await _endpoint.EstablishAsync();
     Console.WriteLine("Endpoint established");
     await CreateConference();
     LyncServerReady(this, new EventArgs());
 }
        /// <summary>
        /// The initialize application endpoint function
        /// </summary>
        public async Task InitializeApplicationEndpointAsync(
            string applicationEndpointUri,
            string callbackUriFormat,
            string resourcesUriFormat,
            string audienceUri,
            string aadClientId,
            string aadClientSecret,
            string appTokenCertThumbprint,
            string instanceId,
            bool isSandBoxEnvionment        = false,
            bool logFullHttpRequestResponse = true)
        {
            this.InstanceId        = instanceId;
            this.ResourceUriFormat = resourcesUriFormat;
            this.CallbackUriFormat = callbackUriFormat;

            var logger = IOCHelper.Resolve <IPlatformServiceLogger>();

            logger.HttpRequestResponseNeedsToBeLogged = logFullHttpRequestResponse;

            ClientPlatformSettings platformSettings = null;

            if (!string.IsNullOrEmpty(appTokenCertThumbprint))
            {
                platformSettings = new ClientPlatformSettings(
                    Guid.Parse(aadClientId),
                    appTokenCertThumbprint,
                    isSandBoxEnvionment
                    );
            }
            else if (!string.IsNullOrEmpty(aadClientSecret))
            {
                platformSettings = new ClientPlatformSettings(
                    aadClientSecret,
                    Guid.Parse(aadClientId),
                    isSandBoxEnvionment
                    );
            }
            else
            {
                throw new InvalidOperationException("Should provide at least one prarameter in aadClientSecret and appTokenCertThumbprint");
            }

            var platform = new ClientPlatform(platformSettings, logger);

            var endpointSettings = new ApplicationEndpointSettings(new SipUri(applicationEndpointUri));

            ApplicationEndpoint = new ApplicationEndpoint(platform, endpointSettings, null);

            var loggingContext = new LoggingContext(Guid.NewGuid());
            await ApplicationEndpoint.InitializeAsync(loggingContext).ConfigureAwait(false);

            await ApplicationEndpoint.InitializeApplicationAsync(loggingContext).ConfigureAwait(false);
        }
Пример #28
0
        public void CanCreateMultipleApplicationEndpoints()
        {
            // Given

            // When
            ApplicationEndpoint applicationEndpoint1 = TestHelper.CreateApplicationEndpoint().ApplicationEndpoint;
            ApplicationEndpoint applicationEndpoint2 = TestHelper.CreateApplicationEndpoint().ApplicationEndpoint;

            // Then
            Assert.IsFalse(ReferenceEquals(applicationEndpoint1, applicationEndpoint2));
        }
Пример #29
0
        public async Task RunAsync(Uri callbackUri)
        {
            var targetUserId = ConfigurationManager.AppSettings["Skype_TargetUserId"];

            m_logger = new SampleAppLogger();

            // Uncomment for debugging
            // m_logger.HttpRequestResponseNeedsToBeLogged = true;

            // You can hook up your own implementation of IEventChannel here
            IEventChannel eventChannel = WebEventChannel.WebEventChannel.Instance;

            // Prepare platform
            var platformSettings = new ClientPlatformSettings(QuickSamplesConfig.AAD_ClientSecret,
                                                              new Guid(QuickSamplesConfig.AAD_ClientId));
            var platform = new ClientPlatform(platformSettings, m_logger);

            // Prepare endpoint
            var endpointSettings    = new ApplicationEndpointSettings(new SipUri(QuickSamplesConfig.ApplicationEndpointId));
            var applicationEndpoint = new ApplicationEndpoint(platform, endpointSettings, eventChannel);

            var loggingContext = new LoggingContext(Guid.NewGuid());
            await applicationEndpoint.InitializeAsync(loggingContext).ConfigureAwait(false);

            await applicationEndpoint.InitializeApplicationAsync(loggingContext).ConfigureAwait(false);

            // Get all the events related to join meeting through our custom callback uri
            platformSettings.SetCustomizedCallbackurl(callbackUri);

            WriteToConsoleInColor("Start to send messaging invitation");
            var invitation = await applicationEndpoint.Application.Communication.StartMessagingAsync(
                "Subject",
                new SipUri(targetUserId),
                null,
                loggingContext).ConfigureAwait(false);

            // Wait for user to accept the invitation
            var conversation = await invitation.WaitForInviteCompleteAsync().ConfigureAwait(false);

            conversation.HandleParticipantChange += Conversation_HandleParticipantChange;
            conversation.MessagingCall.IncomingMessageReceived += Handle_IncomingMessage;

            // Send the initial message
            await conversation.MessagingCall.SendMessageAsync("Hello World!", loggingContext).ConfigureAwait(false);

            WriteToConsoleInColor("Staying in the conversation for 5 minutes");

            // Wait 5 minutes before exiting
            // Since we registered callbacks, we will continue to show message logs
            await Task.Delay(TimeSpan.FromMinutes(5)).ConfigureAwait(false);

            await WebEventChannel.WebEventChannel.Instance.TryStopAsync().ConfigureAwait(false);
        }
Пример #30
0
        private void HandleIncomingAVCall(object sender, IncomingInviteEventArgs <IAudioVideoInvitation> args)
        {
            //Read job settings
            string callbackUri = ConfigurationManager.AppSettings["MyCallbackUri"];
            string agents      = ConfigurationManager.AppSettings["MyAgentList"];


            ApplicationEndpoint ae  = sender as ApplicationEndpoint;
            CallCenterJob       job = new CallCenterJob(args, ae.Application, agents.Split(',', ';'), callbackUri);

            job.Start();
        }
Пример #31
0
        public async Task InitializeAsyncWorksWithNullLoggingContext()
        {
            // Given
            var data = TestHelper.CreateApplicationEndpoint();
            ApplicationEndpoint applicationEndpoint = data.ApplicationEndpoint;

            // When
            await applicationEndpoint.InitializeAsync(null).ConfigureAwait(false);

            // Then
            // No exception
        }
Пример #32
0
      public async Task Run()
      {
          ConsoleLogger logger = new ConsoleLogger();

          logger.HttpRequestResponseNeedsToBeLogged = true;  //Set to true if you want to log all http request and responses

          //Prepare platform

          //For all public developers
          ClientPlatformSettings platformSettings = new ClientPlatformSettings(
              QuickSamplesConfig.AAD_ClientSecret,
              Guid.Parse(QuickSamplesConfig.AAD_ClientId),
              false
              );

          var platform = new ClientPlatform(platformSettings, logger);

          //Prepare endpoint
          var eventChannel     = new FakeEventChannel();
          var endpointSettings = new ApplicationEndpointSettings(new SipUri(QuickSamplesConfig.ApplicationEndpointId));
          ApplicationEndpoint applicationEndpoint = new ApplicationEndpoint(platform, endpointSettings, eventChannel);

          var loggingContext = new LoggingContext(Guid.NewGuid());
          await applicationEndpoint.InitializeAsync(loggingContext).ConfigureAwait(false);

          await applicationEndpoint.InitializeApplicationAsync(loggingContext).ConfigureAwait(false);


          //Schedule meeting
          var adhocMeeting = await applicationEndpoint.Application.GetAdhocMeetingResourceAsync(loggingContext,
                                                                                                new AdhocMeetingInput
            {
                AccessLevel = AccessLevel.Everyone,
                Subject     = Guid.NewGuid().ToString("N") + "testMeeting"
            });

          logger.Information("ad hoc meeting uri : " + adhocMeeting.OnlineMeetingUri);
          logger.Information("ad hoc meeting join url : " + adhocMeeting.JoinUrl);

          //Get anon join token
          AnonymousApplicationTokenResource anonToken = await applicationEndpoint.Application.GetAnonApplicationTokenAsync(loggingContext, new AnonymousApplicationTokenInput
            {
                ApplicationSessionId = Guid.NewGuid().ToString(),                                                                      //Should be unique everytime
                AllowedOrigins       = "https://contoso.com;https://litware.com;http://www.microsoftstore.com/store/msusa/en_US/home", //Fill your own web site, For allow cross domain using
                MeetingUrl           = adhocMeeting.JoinUrl
            }
                                                                                                                           );


          logger.Information("Get anon token : " + anonToken.AuthToken);
          logger.Information("Get discover url for web SDK : " + anonToken.AnonymousApplicationsDiscover.Href);
      }
Пример #33
0
        /// <summary>
        /// The initialize application endpoint function
        /// </summary>
        public async Task InitializeApplicationEndpointAsync(
            string discoverUri,
            string applicationEndpointUri,
            string callbackUriFormat,
            string resourcesUriFormat,
            string aadClientId,
            string aadClientSecret,
            string aadAuthorityUri,
            string aadCertThumbprint,
            string instanceId,
            bool logFullHttpRequestResponse)
        {
            this.InstanceId        = instanceId;
            this.ResourceUriFormat = resourcesUriFormat;
            this.CallbackUriFormat = callbackUriFormat;

            var logger = IOCHelper.Resolve <IPlatformServiceLogger>();

            logger.HttpRequestResponseNeedsToBeLogged = logFullHttpRequestResponse;

            ClientPlatformSettings platformSettings;

            if (aadClientSecret.Length > 0)
            {
                // AAD auth to app using client secret
                platformSettings = new ClientPlatformSettings(
                    new System.Uri(discoverUri),
                    Guid.Parse(aadClientId),
                    null,
                    aadClientSecret
                    );
            }
            else
            {
                // AAD auth to app using cert
                platformSettings = new ClientPlatformSettings(
                    new System.Uri(discoverUri),
                    Guid.Parse(aadClientId),
                    aadCertThumbprint
                    );
            }

            var platform         = new ClientPlatform(platformSettings, logger);
            var endpointSettings = new ApplicationEndpointSettings(new SipUri(applicationEndpointUri));

            ApplicationEndpoint = new ApplicationEndpoint(platform, endpointSettings, null);

            var loggingContext = new LoggingContext(Guid.NewGuid());
            await ApplicationEndpoint.InitializeAsync(loggingContext).ConfigureAwait(false);

            await ApplicationEndpoint.InitializeApplicationAsync(loggingContext).ConfigureAwait(false);
        }
Пример #34
0
        private void Platform_ApplicationEndpointOwnerDiscovered(object sender, ApplicationEndpointSettingsDiscoveredEventArgs e)
        {
            Console.WriteLine("Contact discovered: {0}", e.ApplicationEndpointSettings.OwnerUri);
            
            var settings = e.ApplicationEndpointSettings;
            
            settings.AutomaticPresencePublicationEnabled = true;
            settings.Presence.PresentityType = "automaton";
            settings.Presence.Description = "Toujours disponible !";

            _applicationEndpoint = new ApplicationEndpoint(_CollabPlatform, settings);
            Console.WriteLine("Establishing the endopint");
            _applicationEndpoint.BeginEstablish(EndpointEstablishCompleted, null);
        }
Пример #35
0
 public ToastMessageSample(ApplicationEndpoint endpoint, ILogger logger)
 {
     _appEndpoint = endpoint;
     _logger = logger;
 }
 public OutboundInstantMessagingCallSample(ApplicationEndpoint endpoint, ILogger logger)
 {
     _appEndpoint = endpoint;
     _logger = logger;
 }
 public OutboundAudioCallSample(ApplicationEndpoint endpoint, ILogger logger)
 {
     _appEndpoint = endpoint;
     _logger = logger;
 }
Пример #38
0
 public TransferCallSample(ApplicationEndpoint endpoint, ILogger logger)
 {
     _appEndpoint = endpoint;
     _logger = logger;
 }
 public RecoverFailedTransferSample(ApplicationEndpoint endpoint, ILogger logger)
 {
     _appEndpoint = endpoint;
     _logger = logger;
 }
Пример #40
0
        // Registered event handler for the ApplicationEndpointOwnerDiscovered event on the
        // CollaborationPlatform for the provisioned application.
        static void Platform_ApplicationEndpointOwnerDiscovered(object sender,
            ApplicationEndpointSettingsDiscoveredEventArgs e)
        {
            Console.WriteLine("ApplicationEndpointOwnerDiscovered event was raised during startup of the CollaborationPlatform.");
            Console.WriteLine("The ApplicationEndpointOwnerConfiguration that corresponds to the provisioned application are: ");
            Console.WriteLine("Owner display name is: " + e.ApplicationEndpointSettings.OwnerDisplayName);
            Console.WriteLine("Owner URI is: " + e.ApplicationEndpointSettings.OwnerUri);
            Console.WriteLine("Now retrieving the ApplicationEndpointSettings from the ApplicationEndpointSettingsDiscoveredEventArgs.");

            ApplicationEndpointSettings settings = e.ApplicationEndpointSettings;
            settings.AutomaticPresencePublicationEnabled = true;
            settings.SupportedMimePartContentTypes = new ContentType[] { new ContentType("text/plain") };
            settings.Presence.Description = "AlwaysOnlineBot";

            PreferredServiceCapabilities capabilities = settings.Presence.PreferredServiceCapabilities;

            capabilities.ApplicationSharingSupport = CapabilitySupport.Supported;
            capabilities.AudioSupport = CapabilitySupport.Supported;
            capabilities.InstantMessagingSupport = CapabilitySupport.Supported;
            capabilities.VideoSupport = CapabilitySupport.Supported;

            Console.WriteLine("Initializing the ApplicationEndpoint that corresponds to the provisioned application.");

            // Initalize the endpoint using the settings retrieved above.
            _appEndpoint = new ApplicationEndpoint(_collabPlatform, settings);
            // Wire up the StateChanged event.
            _appEndpoint.StateChanged += Endpoint_StateChanged;
            // Wire up the ApplicationEndpointOwnerPropertiesChanged event.
            _appEndpoint.OwnerPropertiesChanged += Endpoint_ApplicationEndpointOwnerPropertiesChanged;

            try
            {
                // Establish the endpoint.
                _appEndpoint.BeginEstablish(EndEndpointEstablish, _appEndpoint);
            }
            catch (InvalidOperationException iOpEx)
            {
                Console.WriteLine("Invalid Operation Exception: " + iOpEx.ToString());
            }
        }
Пример #41
0
        public void ExtablishOutboundAVCall(ApplicationEndpoint appEndpoint, string destinationSipUri, string message)
        {
            
            try
            {
                Conversation conversation = new Conversation(appEndpoint);
                AudioVideoCall call = new AudioVideoCall(conversation);

                call.BeginEstablish(destinationSipUri,
                    new CallEstablishOptions(),
                    result =>
                    {
                        try
                        {
                            call.EndEstablish(result);
                            SpeakMessage(call.Flow, message);
/*                                string.Format("Hello, {0}. This my UCMA app calling you. " + "Your SIP URI is {1}",
                                call.RemoteEndpoint.Participant.DisplayName,
                                call.RemoteEndpoint.Participant.Uri));
 * */
                        }
                        catch (RealTimeException ex)
                        {
                            Console.WriteLine("Failed establishing AV call {0}", ex);
                        }
                    },
                    null);
            }
            catch (InvalidOperationException ex)
            {
                Console.WriteLine("Failed establishing AV call {0}", ex);
            }
        }
 public AcceptTransfersAndForwardsSample(ApplicationEndpoint endpoint, ILogger logger)
 {
     _appEndpoint = endpoint;
     _logger = logger;
 }
        private void EstablishApplicationEndpoint()
        {
            string contactUri = ConfigurationManager.AppSettings["contactUri"];
            string proxyServerFqdn = ConfigurationManager.AppSettings["proxyServerFqdn"];
            int tlsPort = 5061;
            
            // ApplicationEndpointSettings settings = new ApplicationEndpointSettings(contactUri);                        

            ApplicationEndpointSettings settings = new ApplicationEndpointSettings(contactUri, proxyServerFqdn, tlsPort);
            settings.UseRegistration = true;

            settings.AutomaticPresencePublicationEnabled = true;
            settings.Presence.PresentityType = "automaton";
            settings.Presence.Description = "Always available !";

            PreferredServiceCapabilities capabilities = settings.Presence.PreferredServiceCapabilities;
            capabilities.InstantMessagingSupport = CapabilitySupport.Supported;
            capabilities.AudioSupport = CapabilitySupport.Supported;
            capabilities.VideoSupport = CapabilitySupport.Supported;
            capabilities.ApplicationSharingSupport = CapabilitySupport.Supported;

            _appEndpoint = new ApplicationEndpoint(_collaborationPlatform, settings);
            _appEndpoint.StateChanged += new EventHandler<LocalEndpointStateChangedEventArgs>(_appEndpoint_StateChanged);

            // Register to be notified of incoming calls
            _appEndpoint.RegisterForIncomingCall<AudioVideoCall>(OnAudioVideoCallReceived);
            
            // Register to be notified of incoming instant messaging calls
            _appEndpoint.RegisterForIncomingCall<InstantMessagingCall>(OnInstantMessagingCallReceived);

            _logger.Log("Establishing application endpoint...");
            _appEndpoint.BeginEstablish(OnApplicationEndpointEstablishCompleted, null);
        }
 /// <summary>
 /// Initializes a new instance.
 /// </summary>
 /// <param name="endpoint"></param>
 internal RtcApplicationEndpointEventArgs(ApplicationEndpoint endpoint)
 {
     Endpoint = endpoint;
 }
 public DeclineIncomingAudioCallSample(ApplicationEndpoint endpoint, ILogger logger)
 {
     _appEndpoint = endpoint;
     _logger = logger;
 }
 public SelectivelyAcceptCallsSample(ApplicationEndpoint endpoint, ILogger logger)
 {
     _appEndpoint = endpoint;
     _logger = logger;
 }
        private void OnApplicationEndpointSettingsDiscovered(object sender, ApplicationEndpointSettingsDiscoveredEventArgs args)
        {
            // Keep track of how many endpoints we've found
            // so that we only take one.
            Interlocked.Increment(ref _endpointsDiscovered);

            if (_endpointsDiscovered > 1)
            {
                // We've already found an endpoint
                // and we don't need another one. Sorry!
                return;
            }

            _appEndpoint = new ApplicationEndpoint(_collaborationPlatform, args.ApplicationEndpointSettings);

            _appEndpoint.BeginEstablish(OnApplicationEndpointEstablishCompleted, null);
        }