AtomicInteger status = new AtomicInteger(); soInt.handler(buff -> fail()); soInt.messageHandler(obj -> { switch (status.getAndIncrement()) { case 0:
so.channelHandlerContext().pipeline().addBefore("handler", "decoder", new WebSocket13FrameDecoder(true, false, 1000)); Deque<Object> received = new ArrayDeque<>(); so.messageHandler(received::add); int status = 4000 + TestUtils.randomPositiveInt() % 100; String reason = TestUtils.randomAlphaString(10);
so.writeMessage(new CloseWebSocketFrame(status, reason)); Deque<Object> received = new ArrayDeque<>(); so.messageHandler(received::add); so.closeHandler(v2 -> { assertEquals(1, received.size());
pipeline.addBefore("handler", "http", new HttpServerCodec()); internal.handler(buff -> fail()); internal.messageHandler(obj -> { if (obj instanceof LastHttpContent) { DefaultFullHttpResponse response = new DefaultFullHttpResponse(
server.connectHandler(so -> { NetSocketInternal soi = (NetSocketInternal) so; soi.messageHandler(msg -> fail("Unexpected")); soi.handler(msg -> { ByteBuf byteBuf = msg.getByteBuf(); NetSocketInternal soi = (NetSocketInternal) so; soi.write(Buffer.buffer("Hello World")); soi.messageHandler(msg -> fail("Unexpected")); soi.handler(msg -> { ByteBuf byteBuf = msg.getByteBuf();
so.channelHandlerContext().pipeline().addBefore("handler", "decoder", new WebSocket13FrameDecoder(true, false, 1000)); Deque<Object> received = new ArrayDeque<>(); so.messageHandler(received::add); int status = 4000 + TestUtils.randomPositiveInt() % 100; String reason = TestUtils.randomAlphaString(10);
AtomicInteger status = new AtomicInteger(); soInt.handler(buff -> fail()); soInt.messageHandler(obj -> { switch (status.getAndIncrement()) { case 0:
so.writeMessage(new CloseWebSocketFrame(status, reason)); Deque<Object> received = new ArrayDeque<>(); so.messageHandler(received::add); so.closeHandler(v2 -> { assertEquals(1, received.size());
pipeline.addBefore("handler", "http", new HttpServerCodec()); internal.handler(buff -> fail()); internal.messageHandler(obj -> { if (obj instanceof LastHttpContent) { DefaultFullHttpResponse response = new DefaultFullHttpResponse(
server.connectHandler(so -> { NetSocketInternal soi = (NetSocketInternal) so; soi.messageHandler(msg -> fail("Unexpected")); soi.handler(msg -> { ByteBuf byteBuf = msg.getByteBuf(); NetSocketInternal soi = (NetSocketInternal) so; soi.write(Buffer.buffer("Hello World")); soi.messageHandler(msg -> fail("Unexpected")); soi.handler(msg -> { ByteBuf byteBuf = msg.getByteBuf();
/** * Initialize the client, this will configure Netty's pipeline an set an handler to process the * decoded messages. */ private void init() { // Get the pipeline ChannelPipeline pipeline = so.channelHandlerContext().pipeline(); // Add the memcached message aggregator pipeline.addFirst("aggregator", new BinaryMemcacheObjectAggregator(Integer.MAX_VALUE)); // Add the memcached decoder pipeline.addFirst("memcached", new BinaryMemcacheClientCodec()); // Set the message handler to process memcached message so.messageHandler(this::processResponse); }
@Override public MqttServer listen(int port, String host, Handler<AsyncResult<MqttServer>> listenHandler) { Handler<MqttEndpoint> h1 = endpointHandler; Handler<Throwable> h2 = exceptionHandler; server.connectHandler(so -> { NetSocketInternal soi = (NetSocketInternal) so; ChannelPipeline pipeline = soi.channelHandlerContext().pipeline(); initChannel(pipeline); MqttServerConnection conn = new MqttServerConnection(soi, options); soi.messageHandler(msg -> { synchronized (conn) { conn.handleMessage(msg); } }); conn.init(h1, h2); }); server.listen(port, host, ar -> listenHandler.handle(ar.map(this))); return this; }
@Override public MqttServer listen(int port, String host, Handler<AsyncResult<MqttServer>> listenHandler) { Handler<MqttEndpoint> h1 = endpointHandler; Handler<Throwable> h2 = exceptionHandler; server.connectHandler(so -> { NetSocketInternal soi = (NetSocketInternal) so; ChannelPipeline pipeline = soi.channelHandlerContext().pipeline(); initChannel(pipeline); MqttServerConnection conn = new MqttServerConnection(soi, options); soi.messageHandler(msg -> { synchronized (conn) { conn.handleMessage(msg); } }); conn.init(h1, h2); }); server.listen(port, host, ar -> listenHandler.handle(ar.map(this))); return this; }
void initializeCodec() { decoder = new MessageDecoder(inflight, socket.channelHandlerContext().alloc()); encoder = new MessageEncoder(socket.channelHandlerContext()); ChannelPipeline pipeline = socket.channelHandlerContext().pipeline(); pipeline.addBefore("handler", "decoder", decoder); socket.closeHandler(this::handleClosed); socket.exceptionHandler(this::handleException); socket.messageHandler(msg -> { try { handleMessage(msg); } catch (Exception e) { handleException(e); } }); }
void initializeCodec() { decoder = new MessageDecoder(inflight, socket.channelHandlerContext().alloc()); encoder = new MessageEncoder(socket.channelHandlerContext()); ChannelPipeline pipeline = socket.channelHandlerContext().pipeline(); pipeline.addBefore("handler", "decoder", decoder); socket.closeHandler(this::handleClosed); socket.exceptionHandler(this::handleException); socket.messageHandler(msg -> { try { handleMessage(msg); } catch (Exception e) { handleException(e); } }); }
this.ctx = Vertx.currentContext(); soi.messageHandler(msg -> this.handleMessage(soi.channelHandlerContext(), msg)); soi.closeHandler(v -> handleClosed());
this.ctx = Vertx.currentContext(); soi.messageHandler(msg -> this.handleMessage(soi.channelHandlerContext(), msg)); soi.closeHandler(v -> handleClosed());