kerryjiang / SuperSocket

SuperSocket is a light weight, cross platform and extensible socket server application framework.
Apache License 2.0
3.95k stars 1.15k forks source link

是否支持ASP.net core 6.0 #581

Closed wyywing closed 1 year ago

wyywing commented 2 years ago

我在ASP.net core6.0中引入supersocket,启动后未成功建立对指定端口的监听,ISessionContainer服务也未成功注入。 builder.Host.AsSuperSocketHostBuilder<TextPackageInfo, LinePipelineFilter>() .ConfigureSuperSocket(options => { options.Name = "Echo Server"; options.AddListener(new ListenOptions { Ip = "Any", Port = 4040 } ); }) .UsePackageHandler(async (s, p) => { // echo message back to client await s.SendAsync(Encoding.UTF8.GetBytes(p.Text + "\r\n")); }) .UseInProcSessionContainer() .ConfigureLogging((hostCtx, loggingBuilder) => { loggingBuilder.AddConsole(); });

sharpbetter commented 2 years ago

use Host.CreateDefaultBuilder(args) like Program.cs

using DataCollector.Core;
using SuperSocket;
using SuperSocket.ProtoBase;
using System.Text;

Host.CreateDefaultBuilder(args)
    .ConfigureWebHostDefaults(configure =>
    {
        configure.UseStartup<Startup>();
    })
    .AsSuperSocketHostBuilder<TextPackageInfo, LinePipelineFilter>()
    .UsePackageHandler(async (s, p) =>
    {
        // echo message back to client
        await s.SendAsync(Encoding.UTF8.GetBytes("Hello " + p.Text + "\r\n"));
    })
    .Build()
    .Run();
kerryjiang commented 1 year ago

https://github.com/kerryjiang/SuperSocket/blob/2858a320d911ecebe1c5656366c10f0bee7aaa79/samples/AspNetSample/Program.cs#L8-L25