Beispiel #1
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 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);

            var conversation = invitation.RelatedConversation;

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

            conversation.HandleParticipantChange += Conversation_HandleParticipantChange;

            IAudioVideoCall audioVideoCall = conversation.AudioVideoCall;
            await audioVideoCall.EstablishAsync(loggingContext).ConfigureAwait(false);

            // Wait for the audiovideo call to complete
            await audioVideoCall.WaitForAVFlowConnected().ConfigureAwait(false);

            WriteToConsoleInColor("Showing roaster udpates for 1 minute for meeting : " + adhocMeeting.JoinUrl);

            // Wait for 1 minutes before playing prompt. During this time, we can connect from other skype client and listen prompt.
            // Since we have registered Conversation_HandleParticipantChange, we will also continue to show participant changes in the
            // meeting for this duration.
            await Task.Delay(TimeSpan.FromMinutes(1)).ConfigureAwait(false);

            Uri promptUri = new Uri(mediaUrl);
            // Wait for prompt play to complete
            await audioVideoCall.AudioVideoFlow.PlayPromptAsync(promptUri, loggingContext).ConfigureAwait(false);

            // exit after play prompt. wait for 5 seconds to see all responses.
            await Task.Delay(TimeSpan.FromSeconds(5)).ConfigureAwait(false);
        }
Beispiel #2
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 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.");
        }
Beispiel #3
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 participantUri  = ConfigurationManager.AppSettings["ParticipantUri"];
            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);

            invitation.RelatedConversation.HandleParticipantChange += Conversation_HandleParticipantChange;

            // invite the participant to join the meeting
            WriteToConsoleInColor("Invite " + participantUri + " to join the meeting");
            var participantInvitation = await invitation.RelatedConversation.AddParticipantAsync(participantUri, loggingContext).ConfigureAwait(false);

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

            //remove the participant from the meeting
            foreach (var participant in invitation.RelatedConversation.Participants)
            {
                if (participantUri.Equals(participant.Uri))
                {
                    await participant.EjectAsync(loggingContext).ConfigureAwait(false);
                }
            }

            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);
        }