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); }
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); m_restfulClient.HandleRequestProcessed += (sender, args) => { TestHelper.RaiseEventsOnHttpRequest(args, DataUrls.MessagingInvitations, HttpMethod.Post, "Event_MessagingInvitationStarted.json", m_mockEventChannel); TestHelper.RaiseEventsOnHttpRequest(args, DataUrls.MessagingInvitations, HttpMethod.Post, "Event_ConversationConnected.json", m_mockEventChannel); TestHelper.RaiseEventsOnHttpRequest(args, DataUrls.MessagingInvitations, HttpMethod.Post, "Event_ParticipantAdded.json", m_mockEventChannel); }; IMessagingInvitation invitation = await applicationEndpoint.Application.Communication .StartMessagingAsync("Test subject", new SipUri("sip:[email protected]"), "https://example.com/callback", m_loggingContext) .ConfigureAwait(false); m_conversation = invitation.RelatedConversation; }
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); }
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); }
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); }
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."); }
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); }
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); }
/// <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); }
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); }
public async Task InitializeAsyncWorksWithNullLoggingContext() { // Given var data = TestHelper.CreateApplicationEndpoint(); ApplicationEndpoint applicationEndpoint = data.ApplicationEndpoint; // When await applicationEndpoint.InitializeAsync(null).ConfigureAwait(false); // Then // No exception }
/// <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); }
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); }
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); }
public async Task ShouldStopEventChannelOnUnitialization() { var data = TestHelper.CreateApplicationEndpoint(); Mock <IEventChannel> mockEventChannel = data.EventChannel; ApplicationEndpoint applicationEndpoint = data.ApplicationEndpoint; await applicationEndpoint.InitializeAsync(new LoggingContext(Guid.NewGuid())).ConfigureAwait(false); // When applicationEndpoint.Uninitialize(); // Then mockEventChannel.Verify(foo => foo.TryStopAsync(), Times.Once); }
public async Task InitializeApplicationAsyncWorksWithNullLoggingContext() { // Given var loggingContext = new LoggingContext(Guid.NewGuid()); var data = TestHelper.CreateApplicationEndpoint(); ApplicationEndpoint applicationEndpoint = data.ApplicationEndpoint; await applicationEndpoint.InitializeAsync(loggingContext).ConfigureAwait(false); // When await applicationEndpoint.InitializeApplicationAsync(null).ConfigureAwait(false); // Then Assert.IsNotNull(applicationEndpoint.Application); Assert.IsTrue(data.RestfulClient.RequestsProcessed("GET " + DataUrls.Application)); }
static void Main(string[] args) { Dictionary <string, string> skypeAuthSettings = new Dictionary <string, string>() { { "AAD_ClientId", "" }, { "AAD_ClientSecret", "" }, { "ApplicationEndpointId", "" }, { "DiscoverUri", "https://api.skypeforbusiness.com/platformservice/discover?Region=northamerica" } }; var logger = new StringLogger(); try { ClientPlatformSettings platformSettings = new ClientPlatformSettings(new Uri(skypeAuthSettings["DiscoverUri"]), new Guid(skypeAuthSettings["AAD_ClientId"]), null, skypeAuthSettings["AAD_ClientSecret"], false); var platform = new ClientPlatform(platformSettings, logger); //Prepare endpoint var endpointSettings = new ApplicationEndpointSettings(new SipUri(skypeAuthSettings["ApplicationEndpointId"])); ApplicationEndpoint applicationEndpoint = new ApplicationEndpoint(platform, endpointSettings, null); var loggingContext = new LoggingContext(Guid.NewGuid()); applicationEndpoint.InitializeAsync().GetAwaiter().GetResult(); applicationEndpoint.InitializeApplicationAsync().GetAwaiter().GetResult(); //Schedule meeting var input = new AdhocMeetingCreationInput(Guid.NewGuid().ToString("N") + "testMeeting"); var adhocMeeting = applicationEndpoint.Application.CreateAdhocMeetingAsync(input, loggingContext).Result; Console.WriteLine("ad hoc meeting uri : " + adhocMeeting.OnlineMeetingUri); Console.WriteLine("ad hoc meeting join url : " + adhocMeeting.JoinUrl); //Get anon join token IAnonymousApplicationToken anonToken = applicationEndpoint.Application.GetAnonApplicationTokenForMeetingAsync(adhocMeeting.JoinUrl, "https://contoso.com;https://litware.com;http://www.microsoftstore.com/store/msusa/en_US/home<https://urldefense.proofpoint.com/v2/url?u=https-3A__contoso.com-3Bhttps-3A_litware.com-3Bhttp-3A_www.microsoftstore.com_store_msusa_en-5FUS_home&d=DwMGaQ&c=Bi8ZWNNcZUBhi-AHLorvrkVH0ArnzxTAZ7C8kNcJoZo&r=uycUjr279qo0kuj5jNiyFqi9adZMUkMtmsdo99NlvRQ&m=7jet88f1Tbswi73IIaQYzhITPDlxR_mzF2flXNxdbwQ&s=ozm8LVnKFoAyQtSX8KWnm56u950cmjrR5fvfEpP1SfM&e=>", Guid.NewGuid().ToString(), loggingContext).Result; Console.WriteLine("Get anon token : " + anonToken.AuthToken); Console.WriteLine("Get discover url for web SDK : " + anonToken.AnonymousApplicationsDiscoverUri); } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.Read(); }
public async Task InitializeApplicationAsyncShouldPopulateApplicationProperty() { var loggingContext = new LoggingContext(Guid.NewGuid()); var data = TestHelper.CreateApplicationEndpoint(); ApplicationEndpoint applicationEndpoint = data.ApplicationEndpoint; await applicationEndpoint.InitializeAsync(loggingContext).ConfigureAwait(false); // Given Assert.IsNull(applicationEndpoint.Application); // When await applicationEndpoint.InitializeApplicationAsync(loggingContext).ConfigureAwait(false); // Then Assert.IsNotNull(applicationEndpoint.Application); }
public async Task InitializingApplicationEndpointStartsEventChannel() { // Given var data = TestHelper.CreateApplicationEndpoint(); Mock <IEventChannel> mockEventChannel = data.EventChannel; ApplicationEndpoint applicationEndpoint = data.ApplicationEndpoint; var loggingContext = new LoggingContext(Guid.NewGuid()); mockEventChannel.Verify(foo => foo.TryStartAsync(), Times.Never); // When await applicationEndpoint.InitializeAsync(loggingContext).ConfigureAwait(false); // Then mockEventChannel.Verify(foo => foo.TryStartAsync(), Times.Once); }
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); ICommunication communication = 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); // Message completed event has to be delivered after the response, so start a new thread to wait some time before delivering the event if (m_deliverMessageCompletedEvent) { Task.Run(async() => { await Task.Delay(TimeSpan.FromMilliseconds(10)).ConfigureAwait(false); TestHelper.RaiseEventsOnHttpRequest(args, DataUrls.SendMessage, HttpMethod.Post, "Event_MessageCompleted.json", m_mockEventChannel); }); } }; // Establish a messaging call IMessagingInvitation invitation = await communication.StartMessagingWithIdentityAsync( "Test subject", "sip:[email protected]", "https://example.com/callback", "Local user", "sip:[email protected]", m_loggingContext).ConfigureAwait(false); TestHelper.RaiseEventsFromFile(m_mockEventChannel, "Event_ConversationConnected.json"); // It has link to the messaging call TestHelper.RaiseEventsFromFile(m_mockEventChannel, "Event_ParticipantAdded.json"); TestHelper.RaiseEventsFromFile(m_mockEventChannel, "Event_MessagingConnected.json"); // It has the messaging call m_messagingCall = invitation.RelatedConversation.MessagingCall; }
private void InitializeEndpoint() { _platformSettings = new ClientPlatformSettings(null, _aadClientId, null, _aadClientSecret, true); var platform = new ClientPlatform(_platformSettings, Logger); _eventChannel = new FakeEventChannel(); var endpointSettings = new ApplicationEndpointSettings(_applicationEndpointId); _applicationEndpoint = new ApplicationEndpoint(platform, endpointSettings, _eventChannel); _applicationEndpoint.InitializeAsync(null).GetAwaiter().GetResult(); _applicationEndpoint.InitializeApplicationAsync(null).GetAwaiter().GetResult(); if (_applicationEndpoint.Application != null) { _isInitialized = true; } }
public async Task Run() { var logger = new SampleAppLogger(); logger.HttpRequestResponseNeedsToBeLogged = true; //Set to true if you want to log all http request and responses //Prepare platform ClientPlatformSettings platformSettings = new ClientPlatformSettings(QuickSamplesConfig.AAD_ClientSecret, Guid.Parse(QuickSamplesConfig.AAD_ClientId)); 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 input = new AdhocMeetingCreationInput(Guid.NewGuid().ToString("N") + "testMeeting"); var adhocMeeting = await applicationEndpoint.Application.CreateAdhocMeetingAsync(loggingContext, input).ConfigureAwait(false); logger.Information("ad hoc meeting uri : " + adhocMeeting.OnlineMeetingUri); logger.Information("ad hoc meeting join url : " + adhocMeeting.JoinUrl); //Get anon join token IAnonymousApplicationToken anonToken = await applicationEndpoint.Application.GetAnonApplicationTokenForMeetingAsync( loggingContext, adhocMeeting.JoinUrl, "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 Guid.NewGuid().ToString() //Should be unique everytime ).ConfigureAwait(false); logger.Information("Get anon token : " + anonToken.AuthToken); logger.Information("Get discover url for web SDK : " + anonToken.AnonymousApplicationsDiscoverUri.ToString()); Console.ForegroundColor = ConsoleColor.Green; logger.Information("RemoteAdvisor sample completed successfully!"); Console.ResetColor(); }
public async Task ShouldHandleIncomingEventWithMalformedBaseUri() { // Given 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); TestHelper.RaiseEventsFromFile(mockEventChannel, "Event_IncomingIMCall_MalformedBaseUri.json"); // When TestHelper.RaiseEventsFromFile(mockEventChannel, "Event_IncomingIMCall.json"); // Then // No exception is thrown }
public async Task ShouldNotThrowOnIncomingAudioVideoInviteIfNoEventHandlerRegistered() { 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 // No event handler registered for applicationEndpoint.HandleIncomingAudioVideoCall // When TestHelper.RaiseEventsFromFile(mockEventChannel, "Event_IncomingAudioCall.json"); // Then // No exception is thrown }
public async Task ShouldRaiseIncomingAudioVideoInvite() { // 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); applicationEndpoint.HandleIncomingAudioVideoCall += (sender, args) => { callReceived = true; }; // When TestHelper.RaiseEventsFromFile(mockEventChannel, "Event_IncomingAudioCall.json"); // Then Assert.IsTrue(callReceived, "AudioVideo call not raised by SDK to the application."); }
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); IAudioVideoInvitation invitation = null; applicationEndpoint.HandleIncomingAudioVideoCall += (sender, args) => invitation = args.NewInvite; TestHelper.RaiseEventsFromFile(m_mockEventChannel, "Event_IncomingAudioCall.json"); TestHelper.RaiseEventsFromFile(m_mockEventChannel, "Event_AudioVideoConnected.json"); m_audioVideoCall = invitation.RelatedConversation.AudioVideoCall; }
private async Task InitializeApplicationEndpointAsync() { //Read application auth settings var applicationEndpointUri = ConfigurationManager.AppSettings["ApplicationEndpointId"]; var aadClientId = ConfigurationManager.AppSettings["AAD_ClientId"]; var aadClientSecret = ConfigurationManager.AppSettings["AAD_ClientSecret"]; //Get singleton logger var logger = UnityHelper.Resolve <IPlatformServiceLogger>(); logger.HttpRequestResponseNeedsToBeLogged = true; //Get singleton event channel var eventChannel = UnityHelper.Resolve <SimpleEventChannel>(); //Initialize platform var platformSettings = new ClientPlatformSettings ( aadClientSecret, Guid.Parse(aadClientId) ); var platform = new ClientPlatform(platformSettings, logger); //Initialize application and application endpoint var endpointSettings = new ApplicationEndpointSettings(new SipUri(applicationEndpointUri)); 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); //Hook up listener for incoming call ApplicationEndpoint.HandleIncomingAudioVideoCall += HandleIncomingAVCall; }
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 SampleAppLogger(); // 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); WriteToConsoleInColor("Please use this url to join the meeting : " + adhocMeeting.JoinUrl); WriteToConsoleInColor("Giving 30 seconds for the user to join the meeting..."); await Task.Delay(TimeSpan.FromSeconds(30)).ConfigureAwait(false); var conversation = invitation.RelatedConversation; var imCall = invitation.RelatedConversation.MessagingCall; if (imCall == null) { WriteToConsoleInColor("No messaging call link found in conversation of the conference."); return; } var messagingInvitation = await imCall.EstablishAsync(loggingContext).ConfigureAwait(false); messagingInvitation.HandleResourceCompleted += OnMessagingResourceCompletedReceived; await messagingInvitation.WaitForInviteCompleteAsync().ConfigureAwait(false); if (imCall.State != CallState.Connected) { WriteToConsoleInColor("Messaging call is not connected."); return; } var modalities = invitation.RelatedConversation.ActiveModalities; WriteToConsoleInColor("Active modalities : "); bool hasMessagingModality = false; foreach (var modality in modalities) { WriteToConsoleInColor(" " + modality.ToString()); if (modality == ConversationModalityType.Messaging) { hasMessagingModality = true; } } await imCall.SendMessageAsync("Hello World.", loggingContext).ConfigureAwait(false); if (!hasMessagingModality) { WriteToConsoleInColor("Failed to connect messaging call.", ConsoleColor.Red); return; } WriteToConsoleInColor("Adding messaging to meeting completed successfully."); }
public async Task RunAsync(Uri callbackUri) { 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); // 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); WriteToConsoleInColor("Please use this url to join the meeting : " + adhocMeeting.JoinUrl); WriteToConsoleInColor("Giving 30 seconds for the user to join the meeting..."); await Task.Delay(TimeSpan.FromSeconds(30)).ConfigureAwait(false); var conversation = invitation.RelatedConversation; var imCall = invitation.RelatedConversation.MessagingCall; if (imCall == null) { WriteToConsoleInColor("No messaging call link found in conversation of the conference."); return; } var messagingInvitation = await imCall.EstablishAsync(loggingContext).ConfigureAwait(false); messagingInvitation.HandleResourceCompleted += OnMessagingInvitationCompleted; await messagingInvitation.WaitForInviteCompleteAsync().ConfigureAwait(false); if (imCall.State != CallState.Connected) { WriteToConsoleInColor("Messaging call is not connected."); return; } var modalities = invitation.RelatedConversation.ActiveModalities; WriteToConsoleInColor("Active modalities : "); bool hasMessagingModality = false; foreach (var modality in modalities) { WriteToConsoleInColor(" " + modality.ToString()); if (modality == ConversationModalityType.Messaging) { hasMessagingModality = true; } } if (!hasMessagingModality) { WriteToConsoleInColor("Failed to connect messaging call.", ConsoleColor.Red); return; } WriteToConsoleInColor("Adding messaging to meeting completed successfully."); WriteToConsoleInColor("Sending Hellow World!"); await imCall.SendMessageAsync("Hello World!", loggingContext).ConfigureAwait(false); WriteToConsoleInColor("Sent Hello World!"); await WebEventChannel.WebEventChannel.Instance.TryStopAsync().ConfigureAwait(false); }