Project

General

Profile

Does tigase support broadcast to all selected user or all user?

tiger zhang
Added about 5 years ago

3ku


Replies (22)

Added by Wojciech Kapcia TigaseTeam about 5 years ago

Please specify - broadcast what? Presence? Message?

Added by tiger zhang about 5 years ago

Message

Added by tiger zhang about 5 years ago

sos

Added by Wojciech Kapcia TigaseTeam about 5 years ago

Currently you can broadcast message only to all online users using admin ad-hoc command BroadcastToOnline.groovy

Added by tiger zhang about 5 years ago

create a chatroom? groupchat?

Added by Wojciech Kapcia TigaseTeam about 5 years ago

Could you explain in detail your use-case and what are you trying to achieve?

Added by tiger zhang about 5 years ago

I want to send a message to all registered users(11465 users), But it take 30 minutes to do this,So i want to a better method to do this. i use smack,

the code like this :

                    Message m = new Message("2120002@jobinfo.com");

        m.setType(Message.Type.normal);// 

        m.setBody("555556");

        connection.sendPacket(m);

i use mutilthread, but not do it rapidly

Added by tiger zhang about 5 years ago

the project will be given to the customer , sos ,help me

Added by Wojciech Kapcia TigaseTeam about 5 years ago

How do you obtain user JID in your current solution?

I would recommend using aforementioned admin ad-hoc script but it would have to be modified to send messages to all users instead of only online ones. The list of all users can be obtained from UserRepository:

tigase.db.UserRepository.getUsers()

Added by tiger zhang about 5 years ago

i do it like you say ,but there is not record in table (msg_history), why?

Added by tiger zhang about 5 years ago

the script has been changed like this:

def userList=user_repo.getUsers()
for(BareJID value : userList){
    def res = msg.copyElementOnly()
    res.initVars(jidFrom, JID.jidInstanceNS(value.toString()))
    res.setPacketTo(JID.jidInstanceNS(fromJid))
       results += res

}
return (Queue)results

Added by tiger zhang about 5 years ago

def user_repo = (UserRepository)userRepository

Added by Wojciech Kapcia TigaseTeam about 5 years ago

tiger zhang wrote:

i do it like you say ,but there is not record in table (msg_history), why?

implementation looks ok.

are the messages processed correctly? are they delivered to recipients and they are only missing from msg_history table?

Added by tiger zhang about 5 years ago

tigase console print the message,i found it look like ok ,but finally i found some type=error message

Added by tiger zhang about 5 years ago

all code is:

/*
 * Tigase Jabber/XMPP Server
 * Copyright (C) 2004-2012 "Artur Hefczyc" <artur.hefczyc@tigase.org>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, version 3 of the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. Look for COPYING file in the top folder.
 * If not, see http://www.gnu.org/licenses/.
 *
 * $Rev: $
 * Last modified by $Author: $
 * $Date: $
 */

/*

4.23 Send Announcement to Online Users as described in XEP-0133:
http://xmpp.org/extensions/xep-0133.html#announce

AS:Description: Send Announcement to Online Users
AS:CommandId: http://jabber.org/protocol/admin#announce
AS:Component: sess-man
*/

package tigase.admin

import tigase.server.*
import tigase.util.*
import tigase.xmpp.*
import tigase.db.*
import tigase.xml.*

def FROM_JID = "from-jid"
def SUBJECT = "subject"
def MSG_TYPE = "msg-type"
def MSG_BODY = "announcement"

def p = (Iq)packet

def fromJid = Command.getFieldValue(p, FROM_JID)
def subject = Command.getFieldValue(p, SUBJECT)
def msg_type = Command.getFieldValue(p, MSG_TYPE)
def body = Command.getFieldValues(p, MSG_BODY)

if (fromJid == null || subject == null || msg_type == null || body == null) {
    def res = (Iq)p.commandResult(Command.DataType.form);
  Command.addTitle(res, "Message to online users")
  Command.addInstructions(res, "Fill out this form to make an announcement to all active users of this service.")

  Command.addFieldValue(res, "FORM_TYPE", "http://jabber.org/protocol/admin", "hidden")

  Command.addFieldValue(res, FROM_JID, fromJid ?: p.getStanzaFrom().getDomain().toString(), "jid-single", "From address")

  Command.addFieldValue(res, SUBJECT, subject ?: "Message from administrators", "Subject")

  def msg_types = ["normal", "headline", "chat" ]
  Command.addFieldValue(res, MSG_TYPE, msg_type ?: msg_types[0], "Type", (String[])msg_types, (String[])msg_types)

  if (body == null) {
     body = [""]
  }

    Command.addFieldMultiValue(res, MSG_BODY, body)

    return res
}

def jidFrom = JID.jidInstanceNS(fromJid)
def type = StanzaType.valueOf(msg_type)
def msg_body = body.join('\n')

def msg = Message.getMessage(null, null, type, msg_body, subject, null, "admin")
Queue results = new LinkedList()
def result = p.commandResult(Command.DataType.result)
Command.addTextField(result, "Note", "Operation successful");
results += result
def conns = (Map)userConnections
conns.each { key, value ->
  if (value.isAuthorized()) {
        def res = msg.copyElementOnly()
        res.initVars(jidFrom, value.getJID())
        res.setPacketTo(key)
        results += res
    }

}

return (Queue)results

Added by tiger zhang about 5 years ago

sos once again

Added by Wojciech Kapcia TigaseTeam about 5 years ago

tiger zhang wrote:

tigase console print the message,i found it look like ok ,but finally i found some type=error message

If you could provide example error message it would be easier to debug the issue. Given that method to retrieve users from database returns all users from database it's possible that there were items related to muc/pubsub/properties and not real users - most likely filtering obtained list to only consists of JIDs from particular VHosts should fix the resulting error messages.

Added by tiger zhang about 5 years ago

Today i meet a problem,the problem is that i send a message to a lot of people ,other people can not login (tigase ) how to avoid this problem

Added by tiger zhang about 5 years ago

sos

Added by Wojciech Kapcia TigaseTeam about 5 years ago

For future reference - please provide more details upfront - it helps solve the issue.

What do you mean "can not login"? Is the connection refused? is there a problem during stream opening / authentication? Do you have many people offline while sending them offline message? do you use offline messages? Do a lot of users connect at once? What is the performance of Tigase (CPU, Memory usage)? What does statistics say? Are there any queues overflows / dropped packets (you can check those using either admin ad-hoc commands and service discovery or JMX monitoring)? Are there any exceptions in the logs? More details please.

Added by tiger zhang about 5 years ago

Login very slowly, send a message to a user, the user receive message slowly. i send a message to a lot of user when they are offline, the number of offline user is 14000,when they are offline ,the message is offline message,when a user is online, they can receive the message ,there age a lot of offline messages record in the table named msg_history , a lot of users never login because they are test users . the performance of Tigase (CPU, Memory usage) is normal .

Added by Wojciech Kapcia TigaseTeam about 5 years ago

Please provide statistics I mentioned earlier (JMX or via ad-hoc). What database do you use? It's probable that it may be the bottleneck in your case.

    (1-22/22)