Search code examples
smack

How to send a messag to multiple recipients in (a)Smack?


I am wondering if there is a way to set multiple targets for a message instead of sending message to multiple targets separately?

 for(i = 0; i<x ; i++){

Message msg = new Message("reza@myhostMessage.Type.chat);
   msg.setBody("HEY");
    try {
        connection.sendPacket(msg);
    } catch (NotConnectedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
  }
}

Solution

  • Simply use MultiRecipientManager.send(XMPPConnection connection, Packet packet, List<String> to, List<String> cc, List<String> bcc)