/** 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);
   }
 }
Example #2
0
 /**
  * Creates a byte[] representation of the PingData, but DISCARDING the view it contains.
  *
  * @param data the PingData instance to serialize.
  * @return
  */
 protected byte[] serializeWithoutView(PingData data) {
   final PingData clone =
       new PingData(
               data.getAddress(), data.isServer(), data.getLogicalName(), data.getPhysicalAddr())
           .coord(data.isCoord());
   try {
     return Util.streamableToByteBuffer(clone);
   } catch (Exception e) {
     log.error(Util.getMessage("ErrorSerializingPingData"), e);
     return null;
   }
 }
 /**
  * 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);
     }
   }
 }
    /**
     * When do a mouse drag, get coordinates ( X and Y) of the mouse, then send Draw command as a
     * message to member of Group
     */
    public void mouseDragged(MouseEvent e) {
      int x = e.getX(), y = e.getX();
      DrawCommand comm = new DrawCommand(DrawCommand.DRAW, x, y, drawColor.getRGB());

      if (noChannel) {
        drawPoint(comm);
        return;
      }

      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);
      }
    }