/// <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; var builder = new StatefulClientBuilder("AudioVideoPlaybackBot", service.Configuration.AadAppId, this.Logger); var authProvider = new AuthenticationProvider( 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); }
/// <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 authProvider = new AuthenticationProvider( options.AppId, options.AppSecret, this.logger); var builder = new StatefulClientBuilder("HueBot", options.AppId, 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); }