Пример #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 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);
        }
Пример #2
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);
        }
Пример #3
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);
        }
Пример #4
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.");
        }
Пример #5
0
        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);
        }