Spigot Server에서 외부 Netty Server를 시작하려고했습니다.Spigot Server에서 외부 Netty Server를 시작하는 방법
제가 시도한 유일한 문제는 처음부터 시작했지만 사용자가 참여할 수없고 서버 시간 초과 문제가 발생했습니다.
이것은 잘 작동하는 Netty-Server에 연결해야하는 Netty-Client의 코드입니다. 이 closeFuture().sync();
를 사용하여 종료하는 코드와
EventLoopGroup eventLoopGroup = EPOLL ? new EpollEventLoopGroup() : new NioEventLoopGroup();
try {
Bootstrap bootstrap = new Bootstrap()
.group(eventLoopGroup)
.option(ChannelOption.TCP_NODELAY, true)
.option(ChannelOption.SO_KEEPALIVE, true)
.channel(EPOLL ? EpollSocketChannel.class : NioSocketChannel.class)
.handler(new ChannelInitializer<Channel>() {
protected void initChannel(Channel channel) throws Exception {
preparePipeline(channel);
}
});
ChannelFuture f = bootstrap.connect(
ReplaySpigotServer.getConnection().configuration.getString("server-host"),
ReplaySpigotServer.getConnection().configuration.getInt("server-port"))
.sync();
f.channel().closeFuture().sync();
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
eventLoopGroup.shutdownGracefully();