@Override public RemotingServer getRemotingServer(AppContext appContext, RemotingServerConfig remotingServerConfig) { return new NettyRemotingServer(appContext, remotingServerConfig); }
@Override protected void channelRead0(ChannelHandlerContext ctx, RemotingCommand msg) throws Exception { processMessageReceived(new NettyChannel(ctx), msg); } }
@Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { com.github.ltsopensource.remoting.Channel channel = new NettyChannel(ctx); final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(channel); LOGGER.info("SERVER: channelInactive, the channel[{}]", remoteAddress); super.channelInactive(ctx); if (channelEventListener != null) { putRemotingEvent(new RemotingEvent(RemotingEventType.CLOSE, remoteAddress, channel)); } }
); final NettyCodecFactory nettyCodecFactory = new NettyCodecFactory(appContext, getCodec());
@Override public void channelActive(ChannelHandlerContext ctx) throws Exception { com.github.ltsopensource.remoting.Channel channel = new NettyChannel(ctx); final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(channel); LOGGER.info("SERVER: channelActive, the channel[{}]", remoteAddress); super.channelActive(ctx); if (channelEventListener != null) { putRemotingEvent(new RemotingEvent(RemotingEventType.CONNECT, remoteAddress, channel)); } }
); final NettyCodecFactory nettyCodecFactory = new NettyCodecFactory(appContext, getCodec());
@Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { com.github.ltsopensource.remoting.Channel channel = new NettyChannel(ctx); final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(channel); LOGGER.info("SERVER: channelInactive, the channel[{}]", remoteAddress); super.channelInactive(ctx); if (channelEventListener != null) { putRemotingEvent(new RemotingEvent(RemotingEventType.CLOSE, remoteAddress, channel)); } }
@Override protected void channelRead0(ChannelHandlerContext ctx, RemotingCommand msg) throws Exception { processMessageReceived(new NettyChannel(ctx), msg); } }
@Override public RemotingServer getRemotingServer(AppContext appContext, RemotingServerConfig remotingServerConfig) { return new NettyRemotingServer(appContext, remotingServerConfig); }
); final NettyCodecFactory nettyCodecFactory = new NettyCodecFactory(appContext, getCodec());
@Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { com.github.ltsopensource.remoting.Channel channel = new NettyChannel(ctx); final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(channel); LOGGER.warn("SERVER: exceptionCaught {}", remoteAddress, cause); if (channelEventListener != null) { putRemotingEvent(new RemotingEvent(RemotingEventType.EXCEPTION, remoteAddress, channel)); } RemotingHelper.closeChannel(channel); } }
@Override protected void channelRead0(ChannelHandlerContext ctx, RemotingCommand msg) throws Exception { processMessageReceived(new NettyChannel(ctx), msg); } }
@Override public RemotingServer getRemotingServer(AppContext appContext, RemotingServerConfig remotingServerConfig) { return new NettyRemotingServer(appContext, remotingServerConfig); }
@Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { com.github.ltsopensource.remoting.Channel channel = new NettyChannel(ctx); final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(channel); LOGGER.warn("SERVER: exceptionCaught {}", remoteAddress, cause); if (channelEventListener != null) { putRemotingEvent(new RemotingEvent(RemotingEventType.EXCEPTION, remoteAddress, channel)); } RemotingHelper.closeChannel(channel); } }
@Override public void channelActive(ChannelHandlerContext ctx) throws Exception { com.github.ltsopensource.remoting.Channel channel = new NettyChannel(ctx); final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(channel); LOGGER.info("SERVER: channelActive, the channel[{}]", remoteAddress); super.channelActive(ctx); if (channelEventListener != null) { putRemotingEvent(new RemotingEvent(RemotingEventType.CONNECT, remoteAddress, channel)); } }
@Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { if (evt instanceof IdleStateEvent) { IdleStateEvent event = (IdleStateEvent) evt; com.github.ltsopensource.remoting.Channel channel = new NettyChannel(ctx); final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(channel); if (event.state().equals(IdleState.ALL_IDLE)) { LOGGER.warn("SERVER: IDLE [{}]", remoteAddress); RemotingHelper.closeChannel(channel); } if (channelEventListener != null) { RemotingEventType remotingEventType = RemotingEventType.valueOf(event.state().name()); putRemotingEvent(new RemotingEvent(remotingEventType, remoteAddress, channel)); } } ctx.fireUserEventTriggered(evt); }
@Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { if (evt instanceof IdleStateEvent) { IdleStateEvent event = (IdleStateEvent) evt; com.github.ltsopensource.remoting.Channel channel = new NettyChannel(ctx); final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(channel); if (event.state().equals(IdleState.ALL_IDLE)) { LOGGER.warn("SERVER: IDLE [{}]", remoteAddress); RemotingHelper.closeChannel(channel); } if (channelEventListener != null) { RemotingEventType remotingEventType = RemotingEventType.valueOf(event.state().name()); putRemotingEvent(new RemotingEvent(remotingEventType, remoteAddress, channel)); } } ctx.fireUserEventTriggered(evt); }
@Override public void channelActive(ChannelHandlerContext ctx) throws Exception { com.github.ltsopensource.remoting.Channel channel = new NettyChannel(ctx); final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(channel); LOGGER.info("SERVER: channelActive, the channel[{}]", remoteAddress); super.channelActive(ctx); if (channelEventListener != null) { putRemotingEvent(new RemotingEvent(RemotingEventType.CONNECT, remoteAddress, channel)); } }
@Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { com.github.ltsopensource.remoting.Channel channel = new NettyChannel(ctx); final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(channel); LOGGER.info("SERVER: channelInactive, the channel[{}]", remoteAddress); super.channelInactive(ctx); if (channelEventListener != null) { putRemotingEvent(new RemotingEvent(RemotingEventType.CLOSE, remoteAddress, channel)); } }
@Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { com.github.ltsopensource.remoting.Channel channel = new NettyChannel(ctx); final String remoteAddress = RemotingHelper.parseChannelRemoteAddr(channel); LOGGER.warn("SERVER: exceptionCaught {}", remoteAddress, cause); if (channelEventListener != null) { putRemotingEvent(new RemotingEvent(RemotingEventType.EXCEPTION, remoteAddress, channel)); } RemotingHelper.closeChannel(channel); } }