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>(); }
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); }
public ChatRoomService(ChatRoomRedisService subscribeService, ChatRoomConfig config) { this.subscribeService = subscribeService; server = new WebSocketServer(config.Port); server.Start(); }