private Futures.WriteFuture write(NioChannel channel, Object msg, boolean flush) { Futures.WriteFuture future = Futures.newWriteFuture(); if (msg == null) { future.setSuccess(true); future.setMsg("msg is null"); future.notifyListeners(); return future; } ByteBuffer buf = null; try { buf = channel.getEncoder().encode(channel, msg); if (buf == null) { future.setSuccess(false); future.setMsg("encode msg error"); future.notifyListeners(); return future; } QUEUE_MAP.get(channel).offer(new WriteRequest(buf, future)); } catch (Exception e) { throw new NioException("encode msg " + msg + " error", e); } if (flush) { doFlush(channel); } return future; }
private Futures.WriteFuture write(NioChannel channel, Object msg, boolean flush) { Futures.WriteFuture future = Futures.newWriteFuture(); if (msg == null) { future.setSuccess(true); future.setMsg("msg is null"); future.notifyListeners(); return future; } ByteBuffer buf = null; try { buf = channel.getEncoder().encode(channel, msg); if (buf == null) { future.setSuccess(false); future.setMsg("encode msg error"); future.notifyListeners(); return future; } QUEUE_MAP.get(channel).offer(new WriteRequest(buf, future)); } catch (Exception e) { throw new NioException("encode msg " + msg + " error", e); } if (flush) { doFlush(channel); } return future; }
private Futures.WriteFuture write(NioChannel channel, Object msg, boolean flush) { Futures.WriteFuture future = Futures.newWriteFuture(); if (msg == null) { future.setSuccess(true); future.setMsg("msg is null"); future.notifyListeners(); return future; } ByteBuffer buf = null; try { buf = channel.getEncoder().encode(channel, msg); if (buf == null) { future.setSuccess(false); future.setMsg("encode msg error"); future.notifyListeners(); return future; } QUEUE_MAP.get(channel).offer(new WriteRequest(buf, future)); } catch (Exception e) { throw new NioException("encode msg " + msg + " error", e); } if (flush) { doFlush(channel); } return future; }