@Override protected void initChannel(DatagramChannel ch) throws Exception { ch.pipeline().addLast(DECODER, ENCODER, responseHandler); } });
@Override protected void initChannel(DatagramChannel ch) throws Exception { ch.pipeline().addLast(DECODER, ENCODER, responseHandler); } });
private void init() { channel.pipeline().addLast("handler", VertxHandler.create(context, this::createConnection)); }
actualCtx.nettyEventLoop().register(channel); if (options.getLogActivity()) { channel.pipeline().addLast("logging", new LoggingHandler()); channel.pipeline().addLast(new DatagramDnsQueryEncoder()); channel.pipeline().addLast(new DatagramDnsResponseDecoder()); channel.pipeline().addLast(new SimpleChannelInboundHandler<DnsResponse>() { @Override protected void channelRead0(ChannelHandlerContext ctx, DnsResponse msg) throws Exception {
private DatagramSocketImpl(VertxInternal vertx, DatagramSocketOptions options) { Transport transport = vertx.transport(); DatagramChannel channel = transport.datagramChannel(options.isIpV6() ? InternetProtocolFamily.IPv6 : InternetProtocolFamily.IPv4); transport.configure(channel, new DatagramSocketOptions(options)); ContextInternal context = vertx.getOrCreateContext(); channel.config().setOption(ChannelOption.DATAGRAM_CHANNEL_ACTIVE_ON_REGISTRATION, true); MaxMessagesRecvByteBufAllocator bufAllocator = channel.config().getRecvByteBufAllocator(); bufAllocator.maxMessagesPerRead(1); context.nettyEventLoop().register(channel); if (options.getLogActivity()) { channel.pipeline().addLast("logging", new LoggingHandler()); } VertxMetrics metrics = vertx.metricsSPI(); this.metrics = metrics != null ? metrics.createDatagramSocketMetrics(options) : null; this.channel = channel; this.context = context; this.demand = Long.MAX_VALUE; }
private void init() { channel.pipeline().addLast("handler", VertxHandler.create(context, this::createConnection)); }
actualCtx.nettyEventLoop().register(channel); if (options.getLogActivity()) { channel.pipeline().addLast("logging", new LoggingHandler()); channel.pipeline().addLast(new DatagramDnsQueryEncoder()); channel.pipeline().addLast(new DatagramDnsResponseDecoder()); channel.pipeline().addLast(new SimpleChannelInboundHandler<DnsResponse>() { @Override protected void channelRead0(ChannelHandlerContext ctx, DnsResponse msg) throws Exception {
private DatagramSocketImpl(VertxInternal vertx, DatagramSocketOptions options) { Transport transport = vertx.transport(); DatagramChannel channel = transport.datagramChannel(options.isIpV6() ? InternetProtocolFamily.IPv6 : InternetProtocolFamily.IPv4); transport.configure(channel, new DatagramSocketOptions(options)); ContextInternal context = vertx.getOrCreateContext(); if (context.isMultiThreadedWorkerContext()) { throw new IllegalStateException("Cannot use DatagramSocket in a multi-threaded worker verticle"); } channel.config().setOption(ChannelOption.DATAGRAM_CHANNEL_ACTIVE_ON_REGISTRATION, true); MaxMessagesRecvByteBufAllocator bufAllocator = channel.config().getRecvByteBufAllocator(); bufAllocator.maxMessagesPerRead(1); context.nettyEventLoop().register(channel); if (options.getLogActivity()) { channel.pipeline().addLast("logging", new LoggingHandler()); } VertxMetrics metrics = vertx.metricsSPI(); this.metrics = metrics != null ? metrics.createDatagramSocketMetrics(options) : null; this.channel = channel; this.context = context; this.demand = Long.MAX_VALUE; }
@Override protected void initChannel(DatagramChannel ch) throws Exception { ch.pipeline().addLast(DECODER, ENCODER, responseHandler); } });
@Override protected void initChannel(DatagramChannel ch) throws Exception { ch.pipeline().addLast(DECODER, ENCODER, responseHandler); } });
@Override protected void initChannel(DatagramChannel ch) throws Exception { ch.pipeline().addLast(DECODER, ENCODER, responseHandler); } });
protected void initChannel(DatagramChannel channel) throws Exception { LwCommServiceImpl.LOGGER.info("Initializing channel: '{}'", channel); channels.add(channel); channel.pipeline().addLast(channelHandler); } });
@Override protected void initChannel(DatagramChannel ch) throws Exception { ch.pipeline().addLast("logger", new LoggingHandler()); ch.pipeline().addLast("packetDecoder", new UdpPacketToByteBuf()); ch.pipeline().addLast("buffer", new MetricsBufferDecoder()); ch.pipeline().addLast("frame", new DelimiterBasedFrameDecoder(8192, true, Delimiters.lineDelimiter())); ch.pipeline().addLast("putDecoder", new UdpDecoder()); ch.pipeline().addLast("udpRelayHandler", new UdpRelayHandler(metricResolver, udpClientPool)); } };
@Override protected void initChannel(DatagramChannel ch) throws Exception { ch.pipeline().addLast("logger", new LoggingHandler()); ch.pipeline().addLast("packetDecoder", new UdpPacketToByteBuf()); ch.pipeline().addLast("buffer", new MetricsBufferDecoder()); ch.pipeline().addLast("frame", new DelimiterBasedFrameDecoder(8192, true, Delimiters.lineDelimiter())); ch.pipeline().addLast("putDecoder", new UdpDecoder()); ch.pipeline().addLast("putHandler", new TcpPutHandler(dataStore)); } };
@Override protected void initChannel(DatagramChannel ch) throws Exception { ChannelPipeline pl = ch.pipeline(); // 用于调试,netty会在控制台输出详细日志 if (this.openDebugLogging){ pl.addLast(new LoggingHandler(LogLevel.INFO)); } pl.addLast("bytesDecoder", new ByteArrayDecoder()); // 业务处理器 pl.addLast(new JGateChannelHandler());// 业务逻辑处理 } }
void bindChannel(Function<? super NettyChannel, ? extends Publisher<Void>> handler, DatagramChannel ioChannel) { ChannelPipeline pipeline = ioChannel.pipeline(); if (log.isDebugEnabled()) { pipeline.addLast(new LoggingHandler(UdpServer.class)); } pipeline.addLast(new NettyChannelHandler<>(handler, this, ioChannel), new ChannelOutboundHandlerAdapter()); }
@Override protected void initChannel(DatagramChannel channel) throws Exception { this.channel = channel; channel.pipeline() .addLast("simpleRaknetHandler", new SimpleRakNetPacketCodec()) .addLast("raknetDirectPacketHandler", new RakNetDirectPacketHandler(server)) .addLast("raknetDatagramHandler", new DatagramRakNetPacketCodec(server)) .addLast("voxelwindDatagramHandler", new RakNetDatagramHandler(server)) .addLast("tailHandler", new TailHandler()); }
@Override public void initChannel(DatagramChannel ch) throws Exception { ChannelPipeline pipeline = ch.pipeline(); SimpleClientHandler simpleClientHandler = new SimpleClientHandler(isOnlineFuture, scenarioHandler); simpleClientHandler.setScenario(scenarioHandler); pipeline.addLast("framer", new UdpSimpleClientFramer()); pipeline.addLast("handler", simpleClientHandler); isOnlineFuture = null; }
@Override protected void initChannel(DatagramChannel ch) throws Exception { ch.pipeline().addLast(PipelineHandlers.OF_DATAGRAMPACKET_HANDLER.name(), new OFDatagramPacketHandler(getSwitchConnectionHandler())); OFDatagramPacketDecoder ofDatagramPacketDecoder = new OFDatagramPacketDecoder(); ofDatagramPacketDecoder.setDeserializationFactory(getDeserializationFactory()); ch.pipeline().addLast(PipelineHandlers.OF_DATAGRAMPACKET_DECODER.name(), ofDatagramPacketDecoder); OFDatagramPacketEncoder ofDatagramPacketEncoder = new OFDatagramPacketEncoder(); ofDatagramPacketEncoder.setSerializationFactory(getSerializationFactory()); ch.pipeline().addLast(PipelineHandlers.OF_ENCODER.name(), ofDatagramPacketEncoder); } }
@Override public void initChannel(final DatagramChannel ch) throws Exception { if (null != nettyOptions && null != nettyOptions.pipelineConfigurer()) { nettyOptions.pipelineConfigurer().accept(ch.pipeline()); } bindChannel(channelHandler, ch); } }).bind();