List of usage examples for io.netty.channel ChannelHandlerContext fireUserEventTriggered
@Override ChannelHandlerContext fireUserEventTriggered(Object evt);
From source file:com.whizzosoftware.wzwave.channel.outbound.FrameQueueHandler.java
License:Open Source License
private void sendNextFrame(ChannelHandlerContext ctx) { if (pendingQueue.size() > 0) { FrameWrite fw = pendingQueue.pop(); logger.trace("Sending next queued data frame: {}", fw.frame); ctx.writeAndFlush(fw.frame, fw.promise); fw.frame.incremenentSendCount(); ctx.fireUserEventTriggered(new DataFrameSentEvent(fw.frame, fw.isListeningNode)); } else {//from w w w . j a v a 2s .c om logger.trace("No pending data frames to send"); } }
From source file:com.zaradai.distributor.messaging.netty.handler.AbstractHandshakeHandler.java
License:Apache License
private void notifyHandshakeSuccess(ChannelHandlerContext handlerContext) { removeFromPipeline(handlerContext);// www. j av a2 s . c o m try { handshakePromise.setSuccess(handlerContext.channel()); handlerContext.fireUserEventTriggered(HandshakeCompletionEvent.SUCCESS); LOGGER.info("Success"); } catch (IllegalStateException e) { LOGGER.debug("Unable to set success", e); handlerContext.fireUserEventTriggered(new HandshakeCompletionEvent(e)); handlerContext.close(); } }
From source file:com.zaradai.distributor.messaging.netty.handler.AbstractHandshakeHandler.java
License:Apache License
private void notifyHandshakeFailure(ChannelHandlerContext handlerContext, Throwable cause) { removeFromPipeline(handlerContext);//from w w w . j a va 2 s . c o m if (!inErrorAndClosing) { try { inErrorAndClosing = true; handshakePromise.setFailure(cause); } finally { handlerContext.fireUserEventTriggered(new HandshakeCompletionEvent(cause)); handlerContext.close(); LOGGER.info("Failure in handshake", cause); } } }
From source file:com.zhang.handler.NettyChannelPoolHandler.java
License:Apache License
/** * @see io.netty.channel.ChannelInboundHandlerAdapter#userEventTriggered(io.netty.channel.ChannelHandlerContext, java.lang.Object) *///from w w w . j ava 2 s . c om @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) { if (evt instanceof IdleStateEvent) { logger.log(Level.WARNING, "remove idle channel: " + ctx.channel()); ctx.channel().close(); } else { ctx.fireUserEventTriggered(evt); } }
From source file:com.zhucode.longio.transport.netty.AbstractNettyHandler.java
License:Open Source License
@Override protected void process(ChannelHandlerContext ctx, ByteBuf buf) throws ProtocolException { byte[] bytes = new byte[buf.readableBytes()]; buf.readBytes(bytes);//from ww w . j av a 2 s . c o m MessageBlock mb = pp.decode(bytes); if (mb.getCmd() == 0) { ctx.fireUserEventTriggered(new PongEvent()); return; } mb.setConnector(this.connector); mb.setProtocol(pp); mb.setSessionId(ctx.channel().attr(NettyConnector.sessionKey).get()); mb.setLocalAddress(ctx.channel().localAddress()); mb.setRemoteAddress(ctx.channel().remoteAddress()); this.dispatcher.dispatch(mb); }
From source file:com.zhucode.longio.transport.netty.HttpClientHandler.java
License:Open Source License
private void handleHttp(ChannelHandlerContext ctx, Object msg) { FullHttpResponse res = (FullHttpResponse) msg; ByteBuf bb = res.content();/* w ww . jav a 2s . c o m*/ byte[] bytes = new byte[bb.readableBytes()]; bb.readBytes(bytes); try { MessageBlock mb = pp.decode(bytes); if (mb.getCmd() == 0) { ctx.fireUserEventTriggered(new PingEvent()); return; } processRevMessage(ctx, mb); } catch (ProtocolException e) { e.printStackTrace(); } }
From source file:com.zhucode.longio.transport.netty.RawSocketClientHandler.java
License:Open Source License
@Override public void channelRead(ChannelHandlerContext ctx, Object message) throws Exception { ByteBuf buf = (ByteBuf) message;//w w w . j a v a 2 s . c o m byte[] bytes = new byte[buf.readableBytes()]; buf.readBytes(bytes); try { MessageBlock mb = pp.decode(bytes); if (mb.getCmd() == 0) { ctx.fireUserEventTriggered(new PingEvent()); return; } processRevMessage(ctx, mb); } catch (ProtocolException e) { e.printStackTrace(); } finally { buf.release(); } }
From source file:discord4j.common.close.CloseHandlerAdapter.java
License:Open Source License
@Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) { if (evt instanceof SslCloseCompletionEvent) { SslCloseCompletionEvent closeEvent = (SslCloseCompletionEvent) evt; if (!closeEvent.isSuccess()) { log.debug("Abnormal close status: {}", closeEvent.cause().toString()); closeStatus.set(new CloseStatus(1006, closeEvent.cause().toString())); }//from w w w . j a v a 2 s.c o m } ctx.fireUserEventTriggered(evt); }
From source file:io.grapebaba.vineyard.grape.heartbeat.HeartbeatClientHandler.java
License:Apache License
@Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { if (evt instanceof IdleStateEvent) { IdleStateEvent event = (IdleStateEvent) evt; if (event == IdleStateEvent.WRITER_IDLE_STATE_EVENT) { ctx.writeAndFlush(new HeartbeatRequestMessage()); }/* ww w . ja v a 2s .co m*/ } else { ctx.fireUserEventTriggered(evt); } }
From source file:io.grapebaba.vineyard.grape.heartbeat.HeartbeatServerHandler.java
License:Apache License
@Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { if (evt instanceof IdleStateEvent) { IdleStateEvent event = (IdleStateEvent) evt; if (event == IdleStateEvent.READER_IDLE_STATE_EVENT) { ctx.disconnect();/* ww w . j av a 2 s.com*/ } } else { ctx.fireUserEventTriggered(evt); } }