Пример #1
0
  /** {@inheritDoc} */
  @Nullable
  @Override
  public Object decode(GridNioSession ses, ByteBuffer buf) throws IOException, GridException {
    GridTcpCommunicationMessageAdapter msg = ses.removeMeta(MSG_META_KEY);
    UUID nodeId = ses.meta(GridNioServer.DIFF_VER_NODE_ID_META_KEY);

    if (msg == null && buf.hasRemaining())
      msg = GridTcpCommunicationMessageFactory.create(buf.get());

    boolean finished = false;

    if (buf.hasRemaining()) finished = msgReader.read(nodeId, msg, buf);

    if (finished) return msg;
    else {
      ses.addMeta(MSG_META_KEY, msg);

      return null;
    }
  }