public static SuperSocketHostBuilder <TReceivePackage> ConfigureSuperSocket <TReceivePackage>(this SuperSocketHostBuilder <TReceivePackage> hostBuilder, Action <ServerOptions> configurator)
 {
     return((hostBuilder as ISuperSocketHostBuilder)
            .ConfigureSuperSocket(configurator)
            .AsSuperSocketBuilder <TReceivePackage>());
 }
 public static SuperSocketHostBuilder <TReceivePackage> ConfigurePackageHandler <TReceivePackage>(this SuperSocketHostBuilder <TReceivePackage> hostBuilder, Func <IAppSession, TReceivePackage, ValueTask> packageHandler)
     where TReceivePackage : class
 {
     return(hostBuilder.UsePackageHandler(packageHandler));
 }
 public static SuperSocketHostBuilder <TReceivePackage> ConfigurePackageDecoder <TReceivePackage>(this SuperSocketHostBuilder <TReceivePackage> hostBuilder, IPackageDecoder <TReceivePackage> packageDecoder)
     where TReceivePackage : class
 {
     return(hostBuilder.UsePackageDecoder(packageDecoder));
 }
 private static SuperSocketHostBuilder <TReceivePackage> ConfigureErrorHandler <TReceivePackage>(SuperSocketHostBuilder <TReceivePackage> hostBuilder, Func <IAppSession, PackageHandlingException <TReceivePackage>, ValueTask <bool> > errorHandler)
     where TReceivePackage : class
 {
     return(hostBuilder.ConfigureServices(
                (hostCtx, services) =>
     {
         services.AddSingleton <Func <IAppSession, PackageHandlingException <TReceivePackage>, ValueTask <bool> > >(errorHandler);
     }
                ) as SuperSocketHostBuilder <TReceivePackage>);
 }
 public static SuperSocketHostBuilder <TReceivePackage> ConfigurePackageHandler <TReceivePackage>(this SuperSocketHostBuilder <TReceivePackage> hostBuilder, Func <IAppSession, TReceivePackage, ValueTask> packageHandler, Func <IAppSession, PackageHandlingException <TReceivePackage>, ValueTask <bool> > errorHandler = null)
     where TReceivePackage : class
 {
     return(hostBuilder.UsePackageHandler(packageHandler, errorHandler: errorHandler));
 }
 public static SuperSocketHostBuilder <TReceivePackage> ConfigurePackageHandler <TReceivePackage>(this SuperSocketHostBuilder <TReceivePackage> hostBuilder, Func <IAppSession, TReceivePackage, Task> packageHandler)
     where TReceivePackage : class
 {
     return(ConfigurePackageHandlerCore <TReceivePackage>(hostBuilder, packageHandler) as SuperSocketHostBuilder <TReceivePackage>);
 }
        private static SuperSocketHostBuilder <TReceivePackage> ConfigurePackageHandlerCore <TReceivePackage>(SuperSocketHostBuilder <TReceivePackage> hostBuilder, Func <IAppSession, TReceivePackage, Task> packageHandler, Func <IAppSession, PackageHandlingException <TReceivePackage>, ValueTask <bool> > errorHandler = null)
            where TReceivePackage : class
        {
            if (packageHandler == null)
            {
                return(hostBuilder);
            }

            return(hostBuilder.ConfigureServices(
                       (hostCtx, services) =>
            {
                services.AddSingleton <IPackageHandler <TReceivePackage> >(new DelegatePackageHandler <TReceivePackage>(packageHandler));

                if (errorHandler != null)
                {
                    services.AddSingleton <Func <IAppSession, PackageHandlingException <TReceivePackage>, ValueTask <bool> > >(errorHandler);
                }
            }
                       ) as SuperSocketHostBuilder <TReceivePackage>);
        }
        public static SuperSocketHostBuilder <TReceivePackage> UsePipelineFilterFactory <TReceivePackage>(this SuperSocketHostBuilder <TReceivePackage> hostBuilder, Func <object, IPipelineFilter <TReceivePackage> > filterFactory)
            where TReceivePackage : class
        {
            var builder = hostBuilder.ConfigureServices(
                (hostCtx, services) =>
            {
                services.AddSingleton <Func <object, IPipelineFilter <TReceivePackage> > >(filterFactory);
            }
                ) as SuperSocketHostBuilder <TReceivePackage>;

            return(builder.UsePipelineFilterFactory <DelegatePipelineFilterFactory <TReceivePackage> >());
        }
 public static SuperSocketHostBuilder <TReceivePackage> ConfigureSuperSocket <TReceivePackage>(this SuperSocketHostBuilder <TReceivePackage> hostBuilder, Action <ServerOptions> configurator)
     where TReceivePackage : class
 {
     return(hostBuilder.ConfigureServices(
                (hostCtx, services) =>
     {
         services.Configure <ServerOptions>(configurator);
     }
                ) as SuperSocketHostBuilder <TReceivePackage>);
 }
Ejemplo n.º 10
0
 private static SuperSocketHostBuilder <TReceivePackage> ConfigurePackageDecoderCore <TReceivePackage>(SuperSocketHostBuilder <TReceivePackage> hostBuilder, IPackageDecoder <TReceivePackage> packageDecoder)
     where TReceivePackage : class
 {
     return(hostBuilder.ConfigureServices(
                (hostCtx, services) =>
     {
         services.AddSingleton <IPackageDecoder <TReceivePackage> >(packageDecoder);
     }
                ) as SuperSocketHostBuilder <TReceivePackage>);
 }