Search in sources :

Example 1 with ServerInfoRequestHandler

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;
    });
}
Also used : ChannelFuture(org.jboss.netty.channel.ChannelFuture) InetSocketAddress(java.net.InetSocketAddress) Channel(org.jboss.netty.channel.Channel) ServerInfoRequestHandler(org.terasology.network.internal.ServerInfoRequestHandler)

Example 2 with ServerInfoRequestHandler

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;
}
Also used : ProtobufEncoder(org.jboss.netty.handler.codec.protobuf.ProtobufEncoder) ClientHandshakeHandler(org.terasology.network.internal.ClientHandshakeHandler) ZlibDecoder(org.jboss.netty.handler.codec.compression.ZlibDecoder) MetricRecordingHandler(org.terasology.network.internal.MetricRecordingHandler) ProtobufDecoder(org.jboss.netty.handler.codec.protobuf.ProtobufDecoder) ProtobufVarint32LengthFieldPrepender(org.jboss.netty.handler.codec.protobuf.ProtobufVarint32LengthFieldPrepender) LengthFieldBasedFrameDecoder(org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder) ProtobufVarint32FrameDecoder(org.jboss.netty.handler.codec.protobuf.ProtobufVarint32FrameDecoder) JoinStatusImpl(org.terasology.network.internal.JoinStatusImpl) ChannelPipeline(org.jboss.netty.channel.ChannelPipeline) ServerInfoRequestHandler(org.terasology.network.internal.ServerInfoRequestHandler)

Aggregations

ServerInfoRequestHandler (org.terasology.network.internal.ServerInfoRequestHandler)2 InetSocketAddress (java.net.InetSocketAddress)1 Channel (org.jboss.netty.channel.Channel)1 ChannelFuture (org.jboss.netty.channel.ChannelFuture)1 ChannelPipeline (org.jboss.netty.channel.ChannelPipeline)1 ZlibDecoder (org.jboss.netty.handler.codec.compression.ZlibDecoder)1 LengthFieldBasedFrameDecoder (org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder)1 ProtobufDecoder (org.jboss.netty.handler.codec.protobuf.ProtobufDecoder)1 ProtobufEncoder (org.jboss.netty.handler.codec.protobuf.ProtobufEncoder)1 ProtobufVarint32FrameDecoder (org.jboss.netty.handler.codec.protobuf.ProtobufVarint32FrameDecoder)1 ProtobufVarint32LengthFieldPrepender (org.jboss.netty.handler.codec.protobuf.ProtobufVarint32LengthFieldPrepender)1 ClientHandshakeHandler (org.terasology.network.internal.ClientHandshakeHandler)1 JoinStatusImpl (org.terasology.network.internal.JoinStatusImpl)1 MetricRecordingHandler (org.terasology.network.internal.MetricRecordingHandler)1