public void sendElection() {
   this.isMaster = true;
   SpreadMessage message = new SpreadMessage();
   try {
     message.setType(MessageType.ELECTION.code);
     message.setObject(id);
     message.addGroup(groupName);
     message.setReliable();
     GroupConnection.getInstance().getConnection().multicast(message);
   } catch (SpreadException e) {
     e.printStackTrace();
   }
 }
 public void processMessage(SpreadMessage message) throws SpreadException {
   switch (message.getType()) {
     case 0:
       processElection(message);
       break;
     default:
       break;
   }
 }
  private void processElection(SpreadMessage message) {
    String mes;
    try {
      mes = ((Integer) message.getObject()) + "";
      int id = Integer.valueOf(mes);

      if (this.id > id) {
        sendElection();
      } else {
        if (this.id != id) this.isMaster = false;
      }
    } catch (SpreadException e) {
      e.printStackTrace();
    }
  }