DotNetty
DotNetty copied to clipboard
How to solve the program freezing when calling bootstrap.BindAsync(localAddress).Result in Unity?
How to solve the program freezing when calling bootstrap.BindAsync(localAddress).Result in Unity?
Code:
private void init () {
_executorPool = executorPool;
_executorPool.CreateMessageExecutor();
_eventLoopGroup = eventLoopGroup;
_scheduleThread = new EventLoopScheduleThread();
bootstrap = new Bootstrap();
bootstrap.Group(_eventLoopGroup);
bootstrap.ChannelFactory(() => new SocketDatagramChannel(AddressFamily.InterNetwork));
bootstrap.Handler(new ActionChannelInitializer<SocketDatagramChannel>(channel =>
{
var pipeline = channel.Pipeline;
pipeline.AddLast(new ClientChannelHandler(_channelManager,channelConfig));
}));
}
private static IChannel bindLocal(Bootstrap bootstrap,EndPoint localAddress = null)
{
if (localAddress == null)
{
localAddress = new IPEndPoint(IPAddress.Any, 0);
}
// ------> program freezing <------
return bootstrap.BindAsync(localAddress).Result;
}
Same for me.