Openfire broadcast message _ broadcast message sending using the broadcast plug-in

Source: Internet
Author: User
Tags java se

The first article of the New Year in January 4, 2013 ~~

The process of technological research is full of surprises. Today, I deeply feel that, after only one experiment, I have achieved success.

Step 1: Install the broadcast plug-in

Log on to the console as an administrator. The broadcast plug-in is available in available plugins. Select and install the plug-in.

Step 2: view instructions

Http://www.igniterealtime.org/projects/openfire/plugins/broadcast/readme.html

Broadcast Plugin Readme OverviewThe broadcast plugin broadcasts messages to all users in the system or to specific groups. It's primarily useful for sending announcements or notifications. InstallationCopy broadcast.jar into the plugins directory of your Openfire installation. The plugin will then be automatically deployed. To upgrade to a new version, copy the new broadcast.jar file over the existing file.ConfigurationThe broadcast plugin is configured via Openfire system properties. These can be configured under Server/Server Manager/System Properties: plugin.broadcast.serviceName -- the name of the broadcast service. If no value is set, the default is "broadcast". plugin.broadcast.disableGroupPermissions -- true to allow any user to broadcast a message to a group. When false, only group members or administrators can broadcast messages to a group. The default value is false. plugin.broadcast.groupMembersAllowed -- true to also allow group members to send broadcast messages to groups they belong to. When false, only administrators can send broadcast messages to a group. The default value is true. Note that the property value of plugin.broadcast.disableGroupPermissions can effectively override this value by letting anyone send broadcast messages to groups. plugin.broadcast.allowedUsers -- the comma-delimitted list of users allowed to broadcast messages to all connected users at once. When this property isn't set, anyone is allowed to broadcast messages to all users. Users should be specified by their bare JID (e.g. john@myserver.com) plugin.broadcast.all2offline -- true to deliver broadcast messages sent to all@[serviceName].[serverName] to online and offline users. When false or not set only online users get the messages as described below. plugin.broadcast.messagePrefix -- Add a prefix for all broadcast messages. Set this to "(broadcast)" to prepend "(broadcast) ". Using the PluginTo send a broadcast message, send a message to all@[serviceName].[serverName] or [group]@[serviceName].[serverName]. For example, if your server is called foo and the default service name is being used, a message to all@broadcast.foo would be broadcast to all users connected to the server. For the group staff, a message to staff@broadcast.foo would be sent to all users in the group staff that are currently online or offline. Note: for maximum compatability between group implementations, it's recommended that you use lower-case group names in conjunction with the broadcast plugin. 

The story is very detailed. You should read it once and understand how to get it done.

Step 3: Introduce the jsjac. js file and compile the broadcast message method (click here to view the jsjac. js instructions)

// Send broadcast message dml@2013.1.4function sendbcmsg () {var body = document. getelementbyid ("broadcastmsg "). value; body = body. replace (/\ '/ig, "\" "); If (body. length> 2048) {alert ("The message content is too long. Please send the message in multiple parts. "); Return;} If (Body ='') // don't send empty messagereturn false; var amessage = new jsjacmessage (); amessage. settype ('chat'); amessage. setto ('all @ broadcast. xjtu'); // All @ [servicename]. [servername] amessage. setbody (body); var export cmain = opener. top; your cmain. con. send (amessage); window. close (); Return false ;}

Change the target to all @ service name. server name. If you want to broadcast by group, you only need to change all to a specific group name.

Step 4: run the sendbcmsg method and Test

P.s. during the New Year's Day holiday, I tried the questions for the OCP Java SE 6 programmer certification exam. I feel very helpful to myself. If any of you are also interested, please add qq280587412 for mutual improvement ~~

End

Dml@2013.1.4

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.