示例#1
0
文件: Bot.cs 项目: salujamanish/teams
        /// <summary>
        /// Initialize the instance.
        /// </summary>
        /// <param name="service">Service instance.</param>
        /// <param name="logger">Graph logger.</param>
        internal void Initialize(Service service, IGraphLogger logger)
        {
            Validator.IsNull(this.Logger, "Multiple initializations are not allowed.");

            this.Logger   = logger;
            this.Observer = new SampleObserver(logger);

            var name    = this.GetType().Assembly.GetName().Name;
            var builder = new CommunicationsClientBuilder(
                name,
                service.Configuration.AadAppId,
                this.Logger);

            var authProvider = new AuthenticationProvider(
                name,
                service.Configuration.AadAppId,
                service.Configuration.AadAppSecret,
                this.Logger);

            builder.SetAuthenticationProvider(authProvider);
            builder.SetNotificationUrl(service.Configuration.CallControlBaseUrl);
            builder.SetMediaPlatformSettings(service.Configuration.MediaPlatformSettings);
            builder.SetServiceBaseUrl(service.Configuration.PlaceCallEndpointUrl);

            this.Client = builder.Build();
            this.Client.Calls().OnIncoming += this.CallsOnIncoming;
            this.Client.Calls().OnUpdated  += this.CallsOnUpdated;

            this.OnlineMeetings = new OnlineMeetingHelper(authProvider, service.Configuration.PlaceCallEndpointUrl);
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Bot"/> class.
        /// </summary>
        /// <param name="options">The bot options.</param>
        /// <param name="graphLogger">The graph logger.</param>
        /// <param name="serviceContext">Service context.</param>
        public Bot(BotOptions options, IGraphLogger graphLogger, StatefulServiceContext serviceContext)
        {
            this.Options = options;
            this.logger  = graphLogger;

            var name    = this.GetType().Assembly.GetName().Name;
            var builder = new CommunicationsClientBuilder(
                name,
                options.AppId,
                this.logger);

            var authProvider = new AuthenticationProvider(
                name,
                options.AppId,
                options.AppSecret,
                this.logger);

            builder.SetAuthenticationProvider(authProvider);
            builder.SetNotificationUrl(options.BotBaseUrl.ReplacePort(options.BotBaseUrl.Port + serviceContext.NodeInstance()));
            builder.SetMediaPlatformSettings(this.MediaInit(options, serviceContext));
            builder.SetServiceBaseUrl(options.PlaceCallEndpointUrl);

            this.Client = builder.Build();

            this.Client.Calls().OnIncoming += this.CallsOnIncoming;
            this.Client.Calls().OnUpdated  += this.CallsOnUpdated;

            this.OnlineMeetings = new OnlineMeetingHelper(authProvider, options.PlaceCallEndpointUrl);
        }
示例#3
0
        /// <summary>
        /// Initialize the instance.
        /// </summary>
        /// <param name="service">Service instance.</param>
        /// <param name="logger">Graph logger.</param>
        internal void Initialize(IGraphLogger logger)
        {
            Validator.IsNull(this.Logger, "Multiple initializations are not allowed.");

            this.Logger = logger;
            //this.Observer = new SampleObserver(logger);

            var name    = "xyz"; //this.GetType().Assembly.GetName().Name;
            var builder = new CommunicationsClientBuilder(
                name,
                "90f613f2-ccda-4594-b0b6-e456aad1e070",
                this.Logger);

            var authProvider = new AuthenticationProvider(
                name,
                "90f613f2-ccda-4594-b0b6-e456aad1e070",
                "3PP0i2dfUCr8Qz4Nu.1tIS_o~iFD7~47ko",
                this.Logger);
            X509Certificate2 defaultCertificate = this.GetCertificateFromStore();

            builder.SetAuthenticationProvider(authProvider);
            builder.SetNotificationUrl(new Uri("https://1106ba09f44b.ngrok.io/api/JoinCall"));
            builder.SetMediaPlatformSettings(new MediaPlatformSettings()
            {
                MediaPlatformInstanceSettings = new MediaPlatformInstanceSettings()
                {
                    CertificateThumbprint   = defaultCertificate.Thumbprint,
                    InstanceInternalPort    = 8445,
                    InstancePublicIPAddress = IPAddress.Any,
                    InstancePublicPort      = 18003,
                    ServiceFqdn             = "0.bot.contoso.com",
                },
                ApplicationId = Guid.NewGuid().ToString()
            });
            builder.SetServiceBaseUrl(new System.Uri("https://graph.microsoft.com/beta"));

            this.Client = builder.Build();
            //this.Client.Calls().OnIncoming += this.CallsOnIncoming;
            //this.Client.Calls().OnUpdated += this.CallsOnUpdated;

            this.OnlineMeetings = new OnlineMeetingHelper(authProvider, new System.Uri("https://graph.microsoft.com/v1.0"));
        }
示例#4
0
        /// <summary>
        /// Initialize the instance.
        /// </summary>
        /// <param name="service">Service instance.</param>
        /// <param name="logger">Graph logger.</param>
        internal void Initialize(IGraphLogger logger)
        {
            Validator.IsNull(this.Logger, "Multiple initializations are not allowed.");

            this.Logger = logger;
            //this.Observer = new SampleObserver(logger);

            var name    = this.GetType().Assembly.GetName().Name;
            var builder = new CommunicationsClientBuilder(
                "tryoutbot",
                "fc6d5524-ee41-42fd-95d3-e7e448ff4732",
                this.Logger);

            var authProvider = new AuthenticationProvider(
                name,
                "fc6d5524-ee41-42fd-95d3-e7e448ff4732",
                "~Om8rorxCVxw~a2_r.iG30t30OWHqdA~VC",
                this.Logger);
            X509Certificate2 defaultCertificate = this.GetCertificateFromStore();

            builder.SetAuthenticationProvider(authProvider);
            builder.SetNotificationUrl(new Uri("https://1106ba09f44b.ngrok.io/api/calling"));
            builder.SetMediaPlatformSettings(new MediaPlatformSettings()
            {
                MediaPlatformInstanceSettings = new MediaPlatformInstanceSettings()
                {
                    CertificateThumbprint   = defaultCertificate.Thumbprint,
                    InstanceInternalPort    = 8445,
                    InstancePublicIPAddress = new IPAddress(0x0),
                    InstancePublicPort      = 12634,
                    ServiceFqdn             = "0.tcp.ngrok.io", //"0.bot.contoso.com",
                },
                ApplicationId = "fc6d5524-ee41-42fd-95d3-e7e448ff4732"
            });
            builder.SetServiceBaseUrl(new System.Uri("https://graph.microsoft.com/v1.0"));

            this.Client = builder.Build();
            this.Client.Calls().OnIncoming += this.CallsOnIncoming;
            this.Client.Calls().OnUpdated  += this.CallsOnUpdated;

            this.OnlineMeetings = new OnlineMeetingHelper(authProvider, new System.Uri("https://graph.microsoft.com"));
        }
示例#5
0
        /// <summary>
        /// Initialize the instance.
        /// </summary>
        public void Initialize()
        {
            var name    = this.GetType().Assembly.GetName().Name;
            var builder = new CommunicationsClientBuilder(
                name,
                _settings.AadAppId,
                _logger);

            var authProvider = new AuthenticationProvider(
                name,
                _settings.AadAppId,
                _settings.AadAppSecret,
                _logger);

            builder.SetAuthenticationProvider(authProvider);
            builder.SetNotificationUrl(_settings.CallControlBaseUrl);
            builder.SetMediaPlatformSettings(_settings.MediaPlatformSettings);
            builder.SetServiceBaseUrl(_settings.PlaceCallEndpointUrl);

            this.Client = builder.Build();
            this.Client.Calls().OnIncoming += this.CallsOnIncoming;
            this.Client.Calls().OnUpdated  += this.CallsOnUpdated;
        }
示例#6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Bot" /> class.
        /// </summary>
        /// <param name="options">The bot options.</param>
        /// <param name="graphLogger">The graph logger.</param>
        public Bot(BotOptions options, IGraphLogger graphLogger)
        {
            this.BotInstanceUri = CallAffinityMiddleware.GetWebInstanceCallbackUri(options.BotBaseUrl);

            var instanceNotificationUri = CallAffinityMiddleware.GetWebInstanceCallbackUri(
                new Uri(options.BotBaseUrl, HttpRouteConstants.OnIncomingRequestRoute));

            this.graphLogger = graphLogger;
            var name    = this.GetType().Assembly.GetName().Name;
            var builder = new CommunicationsClientBuilder(
                name,
                options.AppId,
                this.graphLogger);

            var authProvider = new AuthenticationProvider(
                name,
                options.AppId,
                options.AppSecret,
                this.graphLogger);

            builder.SetAuthenticationProvider(authProvider);
            builder.SetNotificationUrl(instanceNotificationUri);
            builder.SetServiceBaseUrl(options.PlaceCallEndpointUrl);

            this.Client = builder.Build();
            this.Client.Calls().OnIncoming += this.CallsOnIncoming;
            this.Client.Calls().OnUpdated  += this.CallsOnUpdated;

            this.IncidentStatusManager = new IncidentStatusManager();

            var audioBaseUri = options.BotBaseUrl;

            this.MediaMap[TransferingPromptName] = new MediaPrompt
            {
                MediaInfo = new MediaInfo
                {
                    Uri        = new Uri(audioBaseUri, "audio/responder-transfering.wav").ToString(),
                    ResourceId = Guid.NewGuid().ToString(),
                },
            };

            this.MediaMap[NotificationPromptName] = new MediaPrompt
            {
                MediaInfo = new MediaInfo
                {
                    Uri        = new Uri(audioBaseUri, "audio/responder-notification.wav").ToString(),
                    ResourceId = Guid.NewGuid().ToString(),
                },
            };

            this.MediaMap[BotIncomingPromptName] = new MediaPrompt
            {
                MediaInfo = new MediaInfo
                {
                    Uri        = new Uri(audioBaseUri, "audio/bot-incoming.wav").ToString(),
                    ResourceId = Guid.NewGuid().ToString(),
                },
            };

            this.MediaMap[BotEndpointIncomingPromptName] = new MediaPrompt
            {
                MediaInfo = new MediaInfo
                {
                    Uri        = new Uri(audioBaseUri, "audio/bot-endpoint-incoming.wav").ToString(),
                    ResourceId = Guid.NewGuid().ToString(),
                },
            };

            this.OnlineMeetings = new OnlineMeetingHelper(authProvider, options.PlaceCallEndpointUrl);
        }