@Override public void run() { try { List<Object> objs = channel.getDecoder().decode(channel, message); if (CollectionUtils.isNotEmpty(objs)) { for (Object obj : objs) { eventHandler().messageReceived(channel, obj); } } channel.setLastReadTime(SystemClock.now()); } catch (Exception e) { eventHandler().exceptionCaught(channel, e); } } });
@Override public void run() { try { List<Object> objs = channel.getDecoder().decode(channel, message); if (CollectionUtils.isNotEmpty(objs)) { for (Object obj : objs) { eventHandler().messageReceived(channel, obj); } } channel.setLastReadTime(SystemClock.now()); } catch (Exception e) { eventHandler().exceptionCaught(channel, e); } } });
public void read(NioChannel channel) { try { // TODO 优化 ByteBuffer readBuffer = ByteBuffer.allocate(64 * 1024); final int readCount = channel.socketChannel().read(readBuffer); if (LOGGER.isDebugEnabled()) { LOGGER.debug("read {} bytes", readCount); } if (readCount < 0) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("channel closed by the remote peer"); } channel.close(); } else if (readCount > 0) { readBuffer.flip(); // TODO SSL处理 doMessageReceived(channel, readBuffer); readBuffer.clear(); } } catch (IOException e) { LOGGER.error("IOE while reading : ", e); eventHandler().exceptionCaught(channel, e); } }
public void read(NioChannel channel) { try { // TODO 优化 ByteBuffer readBuffer = ByteBuffer.allocate(64 * 1024); final int readCount = channel.socketChannel().read(readBuffer); if (LOGGER.isDebugEnabled()) { LOGGER.debug("read {} bytes", readCount); } if (readCount < 0) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("channel closed by the remote peer"); } channel.close(); } else if (readCount > 0) { readBuffer.flip(); // TODO SSL处理 doMessageReceived(channel, readBuffer); readBuffer.clear(); } } catch (IOException e) { LOGGER.error("IOE while reading : ", e); eventHandler().exceptionCaught(channel, e); } }
writeFuture.setCause(e); writeFuture.notifyListeners(); eventHandler().exceptionCaught(channel, e); break;
writeFuture.setCause(e); writeFuture.notifyListeners(); eventHandler().exceptionCaught(channel, e); break;
@Override public void run() { try { List<Object> objs = channel.getDecoder().decode(channel, message); if (CollectionUtils.isNotEmpty(objs)) { for (Object obj : objs) { eventHandler().messageReceived(channel, obj); } } channel.setLastReadTime(SystemClock.now()); } catch (Exception e) { eventHandler().exceptionCaught(channel, e); } } });
public void read(NioChannel channel) { try { // TODO 优化 ByteBuffer readBuffer = ByteBuffer.allocate(64 * 1024); final int readCount = channel.socketChannel().read(readBuffer); if (LOGGER.isDebugEnabled()) { LOGGER.debug("read {} bytes", readCount); } if (readCount < 0) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("channel closed by the remote peer"); } channel.close(); } else if (readCount > 0) { readBuffer.flip(); // TODO SSL处理 doMessageReceived(channel, readBuffer); readBuffer.clear(); } } catch (IOException e) { LOGGER.error("IOE while reading : ", e); eventHandler().exceptionCaught(channel, e); } }
writeFuture.setCause(e); writeFuture.notifyListeners(); eventHandler().exceptionCaught(channel, e); break;