public ChatRoomRedisService(IServiceProvider server, ChatRoomConfig config)
 {
     this.server = server;
     this.config = config;
     redisDB     = new CSRedisClient(config.RedisConnectionString);
     behaviors   = new ConcurrentDictionary <string, List <ChatServiceBehavior> >();
     subscribes  = new ConcurrentDictionary <string, SubscribeObject>();
 }
Ejemplo n.º 2
0
        public static IServiceCollection AddChatRoom(this IServiceCollection services, Action <ChatRoomConfig> configAction)
        {
            var config = new ChatRoomConfig();

            configAction.Invoke(config);
            services
            .AddSingleton(config)
            .AddSingleton <ChatRoomService>()
            .AddTransient <ChatServiceBehavior>()
            .AddSingleton <ChatRoomRedisService>();
            return(services);
        }
Ejemplo n.º 3
0
 public ChatRoomService(ChatRoomRedisService subscribeService, ChatRoomConfig config)
 {
     this.subscribeService = subscribeService;
     server = new WebSocketServer(config.Port);
     server.Start();
 }