Exemplo n.º 1
0
  /**
   * Registers an object consisting of the set of attributes in <i>object</i>. The registration will
   * be retained for <i>forHowLong</i> seconds.
   */
  public void register(Attribute[] object, int forHowLong) throws Exception {

    StringBuffer allAttributes = new StringBuffer();
    String completeObject;
    byte[][] messageBytes = {null, null};

    for (int i = 0; i < object.length; i++)
      allAttributes.append(object[i].name + ":" + object[i].value + "\t");
    allAttributes.append("\t");
    completeObject = allAttributes.toString();
    messageBytes[0] = (new CString(completeObject)).toBytes();
    messageBytes[1] = NwsMessage.toBytes(forHowLong);

    messagePrelude();
    NwsMessage.send(connection, NS_REGISTER, NwsMessage.concatenateBytes(messageBytes));
    NwsMessage.receive(connection, this);
    messagePostlude();
  }