Esempio n. 1
0
        public Server(IServiceProvider provider)
        {
            _provider = provider;
            _logger   = provider.GetService <ILoggerFactory>()?.CreateLogger("Chat.Server");

            _eventBus = provider.GetRequiredService <IEventBus>();

            var eventLogger = provider.GetService <ILoggerFactory>()?.CreateLogger("Chat.Server.Events");

            _eventBus.GetEventStream <DomainEvent>().Subscribe(e => eventLogger.LogInformation(
                                                                   e.GetType().Name + " " + JsonConvert.SerializeObject(e)));

            _userRepo     = provider.GetRequiredService <IUserRepository>();
            _chatroomRepo = provider.GetRequiredService <IChatroomRepository>();
            _messageRepo  = provider.GetRequiredService <IMessageRepository>();

            _identityService   = provider.GetRequiredService <IdentityService>();
            _chatroomService   = provider.GetRequiredService <ChatroomService>();
            _messageService    = provider.GetRequiredService <MessageService>();
            _userClientService = provider.GetRequiredService <UserClientService>();

            _chatroomService.EnsureGlobalChatroomCreated();
        }