/** Send Clear command to all members in Group */
 public void sendClearPanelMsg() {
   DrawCommand comm = new DrawCommand(DrawCommand.CLEAR);
   try {
     byte[] buf = Util.streamableToByteBuffer(comm);
     if (use_unicasts) sendToAll(buf);
     else channel.send(new Message(null, null, buf));
   } catch (Exception ex) {
     System.err.println(ex);
   }
 }
 /**
  * Send State (content on WhiteBoard) to all members of Group
  *
  * @param copy
  */
 protected void sendOwnState(final Map<Point, Color> copy) {
   if (copy == null) return;
   for (Point point : copy.keySet()) {
     // we don't need the color: it is our draw_color anyway
     DrawCommand comm = new DrawCommand(DrawCommand.DRAW, point.x, point.y, drawColor.getRGB());
     try {
       byte[] buf = Util.streamableToByteBuffer(comm);
       if (use_unicasts) sendToAll(buf);
       else channel.send(new Message(null, buf));
     } catch (Exception ex) {
       System.err.println(ex);
     }
   }
 }
Beispiel #3
0
  public void run() {
    Random r = new Random();

    while (true) {
      Util.sleep(10);
      try {
        if (transmitting) {
          channel.send(new Message(null, null, new TotalPayload(r.nextInt(255))));
        } else {
          Util.sleep(200);
        }

      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }
 /**
  * Send message to members in members list only.
  *
  * @param buf
  * @throws Exception
  */
 private void sendToAll(byte[] buf) throws Exception {
   for (Address mbr : members) channel.send(new Message(mbr, buf));
 }