private void AddConfigurationAndGatewayServices(IServiceCollection services)
        {
            var cosmosDBConfiguration = new CosmosDBConfiguration();

            Configuration.Bind("CosmosDB", cosmosDBConfiguration);
            services.AddSingleton(cosmosDBConfiguration);

            var eventGridConfiguration = new EventGridConfiguration();

            Configuration.Bind("EventGrid", eventGridConfiguration);
            services.AddSingleton(eventGridConfiguration);

            var websocketConfiguration = new WebsocketConfiguration();

            Configuration.Bind("Websocket", websocketConfiguration);
            services.AddSingleton(websocketConfiguration);

            services.AddSingleton <IDecisionChannel, DecisionChannelRx>();
            services.AddSingleton <IPerceptionChannel, PerceptionChannelRx>();

            if (eventGridConfiguration.Enabled)
            {
                services.AddSingleton(s => new EventGridClient(new TopicCredentials(eventGridConfiguration.PersonProfileContextPerceptionTopicKey)));
                services.AddSingleton <PerceptionChannelAdapterEventGrid>();
            }
            else
            {
                // Individual components and their dependencies, seemlessly replaced by Azure functions in the cloud
                services.AddSingleton(s => new DocumentClient(new Uri(cosmosDBConfiguration.AccountEndpoint), cosmosDBConfiguration.AccountKey));
                services.AddSingleton <PersonComponent>();
                services.AddSingleton <IPersonRepository, PersonRepositoryCosmosDb>();
            }
        }
 private static void ConfigureDependencyInjector(IServiceCollection services)
 {
     QueriesConfiguration.Configure(services);
     WebsocketConfiguration.Configure(services);
     ConfigureEvents(services);
     ConfigureCommands(services);
 }
Example #3
0
        public WebsocketSharpAdapter(WebSocket ws, WebsocketConfiguration config)
        {
            _ws     = ws;
            _config = config;

            ws.OnOpen    += OnWebsocketOpen;
            ws.OnClose   += OnWebsocketClose;
            ws.OnError   += OnWebsocketError;
            ws.OnMessage += OnWebsocketMessage;
        }
Example #4
0
    public IWebsocket Build(WebsocketConfiguration config)
    {
        var websocket = new WebSocket(config.uri);

        websocket.InternalRequest.ConnectTimeout = TimeSpan.FromSeconds(8);

        var adapter = new BestHTTPWebsocketAdapter(websocket);

        websocket.OnOpen      += (_) => config.onOpenCallback(adapter);
        websocket.OnClosed    += (_, code, message) => config.onCloseCallback(adapter, code, message);
        websocket.OnErrorDesc += (_, message) => config.onErrorCallback(adapter, message);
        websocket.OnMessage   += (_, msg) => config.onMessageCallback(adapter, msg);

        return(adapter);
    }
Example #5
0
        public IWebsocket Build(WebsocketConfiguration config)
        {
            var socket = new WebSocket(config.uri.AbsoluteUri);

            return(new WebsocketSharpAdapter(socket, config));
        }
 public DotNetWebSocketAdapter(ClientWebSocket ws, WebsocketConfiguration config, bool async = false)
 {
     this.ws     = ws;
     this.config = config;
     this.async  = async;
 }
        public IWebsocket Build(WebsocketConfiguration config)
        {
            var socket = new ClientWebSocket();

            return(new DotNetWebSocketAdapter(socket, config));
        }
    public IWebsocket Build(WebsocketConfiguration config)
    {
        var socket = WebSocketFactory.CreateInstance(config.uri.AbsoluteUri);

        return(new WebsocketSharpAdapter(socket, config));
    }
Example #9
0
 public IWebsocket Build(WebsocketConfiguration config)
 {
     return(new MockWebsocketAdapter(config));
 }