use of org.terasology.network.internal.ServerInfoRequestHandler in project Terasology by MovingBlocks.
the class ServerInfoService method requestInfo.
public Future<ServerInfoMessage> requestInfo(final String address, final int port) {
return pool.submit(() -> {
InetSocketAddress remoteAddress = new InetSocketAddress(address, port);
ChannelFuture connectCheck = bootstrap.connect(remoteAddress);
connectCheck.syncUninterruptibly();
Channel channel = connectCheck.getChannel();
channel.getCloseFuture().syncUninterruptibly();
ServerInfoRequestHandler handler = channel.getPipeline().get(ServerInfoRequestHandler.class);
ServerInfoMessage serverInfo = handler.getServerInfo();
return serverInfo;
});
}
use of org.terasology.network.internal.ServerInfoRequestHandler in project Terasology by MovingBlocks.
the class InfoRequestPipelineFactory method getPipeline.
@Override
public ChannelPipeline getPipeline() throws Exception {
JoinStatusImpl joinStatus = new JoinStatusImpl();
ChannelPipeline p = Channels.pipeline();
p.addLast(MetricRecordingHandler.NAME, new MetricRecordingHandler());
p.addLast("lengthFrameDecoder", new LengthFieldBasedFrameDecoder(8388608, 0, 3, 0, 3));
p.addLast("inflateDecoder", new ZlibDecoder());
p.addLast("frameDecoder", new ProtobufVarint32FrameDecoder());
p.addLast("protobufDecoder", new ProtobufDecoder(NetData.NetMessage.getDefaultInstance()));
p.addLast("frameEncoder", new ProtobufVarint32LengthFieldPrepender());
p.addLast("protobufEncoder", new ProtobufEncoder());
p.addLast("authenticationHandler", new ClientHandshakeHandler(joinStatus));
p.addLast("connectionHandler", new ServerInfoRequestHandler());
return p;
}
Aggregations