Open cheetahing opened 4 years ago
I try use this code and throw a exception.
Before do it,i know it can't be work.
Can i override like HandlerFactory.Create function?Please tell me how to do.
exception
DotNetty.Transport.Channels.ChannelPipelineException:“MyHandler is not a @Sharable handler, so can't be added or removed multiple times.”
code
public class MyServer
{
public MyServer(MyHandler myHandler)//myHandler is autofac injection object
{
//some code
bootstrap.ChildHandler(new ActionChannelInitializer<IChannel>(channel =>
{
IChannelPipeline pipeline = channel.Pipeline;
pipeline.AddLast(myHandler);//autofac contoller lift time object
}));
}
}
your MyHandler only new once ,so no need DI,you can new MyHandler by hardcode
I want to use autofac,how to contoller MyHandler life time.