Project

General

Profile

Want to find a better way to develop Broadcast message using Tigase

Kenneth Chan
Added about 5 years ago

Hi,

Currently, we are using Smack to develop our XMPP client where to connect to Tigase for the purpose of sending some kind of broadcast message.

However, my code is to send the message one by one like as below,

for(int i=0;i<member.length;i++){

            String jid = member[i].replace("*", "")+"@"+tigase_domain_name+"/Smack";

            String xml;

            xml = xmlString;

            ChatManager m = conn2.getChatManager();

            Chat c = m.createChat(jid, new MessageListener() { 

                public void processMessage(Chat chat, Message msg) {

                }

            });

            CustomMessage customMessage = new CustomMessage(xml,jid);

            try{

                c.sendMessage(customMessage);

            }

            catch(Exception e){

                e.printStackTrace();

            }

        }

It works with the code already, but it sounds stupid for me that, we are sending the message one by one.

Is there any better way to work better with this?

Thanks.

--

Regards,

Kenneth


Replies (3)

Avatar?id=6023&size=32x32

Added by Artur Hefczyc TigaseTeam about 5 years ago

There is an admin ad-hoc command - broadcast a message to all online users. This is what I would use in your case.

Added by Kenneth Chan about 5 years ago

How about I would like to send the broadcast message with a specific group of user, that I don't know they are online or not? (so, offline queue in this case)

Avatar?id=6023&size=32x32

Added by Artur Hefczyc TigaseTeam about 5 years ago

Then I suppose you know all recipients's addresses. In such a case you can implement a new admin ad-hoc command based on the existing one. The new command would accept a list of JIDs and a message text and would generate and send messages to all recipients. Please note, all the commands are implemented in scripting language and you can upload a new command without restarting the server.

    (1-3/3)