public CommandSubProtocolHandler(string name, IServiceProvider serviceProvider, IOptions <CommandOptions> commandOptions, IPackageMapper <WebSocketPackage, TPackageInfo> mapper)
            : base(name)
        {
            var keyType = CommandMiddlewareExtensions.GetKeyType <TPackageInfo>();
            var commandMiddlewareType = typeof(WebSocketCommandMiddleware <,>).MakeGenericType(keyType, typeof(TPackageInfo));

            _commandMiddleware = Activator.CreateInstance(commandMiddlewareType, serviceProvider, commandOptions, mapper) as IPackageHandler <WebSocketPackage>;
        }
        public static WebSocketHostBuilder UseCommand <TPackageInfo, TPackageMapper>(this WebSocketHostBuilder builder)
            where TPackageInfo : class
            where TPackageMapper : class, IPackageMapper <WebSocketPackage, TPackageInfo>, new()
        {
            var keyType = CommandMiddlewareExtensions.GetKeyType <TPackageInfo>();
            var commandMiddlewareType = typeof(WebSocketCommandMiddleware <, ,>).MakeGenericType(keyType, typeof(TPackageInfo), typeof(TPackageMapper));

            return(builder.ConfigureServices((ctx, services) =>
            {
                services.AddSingleton(typeof(IWebSocketCommandMiddleware), commandMiddlewareType);
            }).ConfigureServices((ctx, services) =>
            {
                services.Configure <CommandOptions>(ctx.Configuration?.GetSection("serverOptions")?.GetSection("commands"));
            }) as WebSocketHostBuilder);
        }