Exemplo n.º 1
0
  /**
   * Our network's equivalent to ping
   *
   * @param tag
   * @param num
   */
  public void poke(String tag, int num) {
    // data to send
    Ping.Builder f = eye.Comm.Ping.newBuilder();
    f.setTag(tag);
    f.setNumber(num);

    // payload containing data
    Request.Builder r = Request.newBuilder();
    eye.Comm.Payload.Builder p = Payload.newBuilder();
    p.setPing(f.build());
    r.setBody(p.build());

    // header with routing info
    eye.Comm.Header.Builder h = Header.newBuilder();
    h.setOriginator("client");
    h.setTag("test finger");
    h.setTime(System.currentTimeMillis());
    h.setRoutingId(eye.Comm.Header.Routing.PING);
    r.setHeader(h.build());

    eye.Comm.Request req = r.build();

    try {
      comm.sendMessage(req);
    } catch (Exception e) {
      logger.warn("Unable to deliver message, queuing");
    }
  }
Exemplo n.º 2
0
 /**
  * add an application-level listener to receive messages from the server (as in replies to
  * requests).
  *
  * @param listener
  */
 public void addListener(CommListener listener) {
   comm.addListener(listener);
 }