Home
The Jabber plugin is a tiny Grails plugin for interacting with Jabber services (such as Google talk). You can send messages to Jabber from all your controllers and services, and you can optionally registered a listener in one of your service classes to be notified of incoming messages.
There is a little configuration required in your /conf/Config.groovy file. Add the following section and point it to your jabber server of choice:
chat {
serviceName = "local.decaf"
host = "localhost"
port = 5222
username = "glen"
password = "password"
}
If you’re using it with Google Talk, you’ll want your settings to be something like:
chat {
serviceName = "gmail.com"
host = "talk.google.com"
port = 5222
username = "yourid@gmail.com"
password = "your_password"
}
Once that’s in, you can happily invoke sendJabberMessage(userId, content) from any of your controllers or services:
sendJabberMessage("glen@decaf.local", "Just a tester....")
If you’d like to listen for incoming Jabber messages, you need to add an ‘expose’ list similar to the JMS and Remoting plugin (which I used as the sample template for my plugin) to one of your service classes.
class DemoService {
static expose = [ 'jabber' ]
def onJabberMessage = {msg ->
println "Eeek a message!!! From ${msg.from} with body ${msg.body}"
}
}
And you’re off and running!
