Closed wyywing closed 1 year 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();
我在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(); });