private void handleSharedWrite(SharedWrite event) {
    debug("received SharedWrite");

    try {
      WriteEvent ev = new WriteEvent(mainchannel, Direction.DOWN, this);
      ev.getMessage().pushObject(event.value);
      ev.getMessage().pushInt(event.reg);
      ev.go();
    } catch (AppiaEventException ex) {
      ex.printStackTrace();
    }
  }
  private void handleWriteEvent(WriteEvent event) {
    int reg = event.getMessage().popInt();
    Object val = event.getMessage().popObject();

    value[reg] = val;

    try {
      AckEvent ev = new AckEvent(pp2pchannel, Direction.DOWN, this);
      ev.getMessage().pushInt(reg);
      ev.dest = event.source;
      ev.go();
    } catch (AppiaEventException ex) {
      ex.printStackTrace();
    }
  }