Esempio n. 1
0
  /**
   * write a TaskMessage into a stream
   *
   * <p>Each TaskMessage is encoded as: task ... short(2) len ... int(4) payload ... byte[] *
   */
  private void writeTaskMessage(ChannelBufferOutputStream bout, TaskMessage message)
      throws Exception {
    int payload_len = 0;
    if (message.message() != null) payload_len = message.message().length;

    int task_id = message.task();
    if (task_id > Short.MAX_VALUE)
      throw new RuntimeException("Task ID should not exceed " + Short.MAX_VALUE);

    bout.writeShort((short) task_id);
    bout.writeInt(payload_len);
    if (payload_len > 0) bout.write(message.message());
  }
Esempio n. 2
0
 void write(ChannelBufferOutputStream bout) throws Exception {
   bout.writeShort(code);
   bout.writeLong(System.currentTimeMillis());
   bout.writeInt(port);
 }