Jabber plugin

  • Tags: xmpp, jabber
  • Latest: 0.1
  • Last Updated: 29 June 2009
  • Grails version: 1.1.1 > *
  • Authors: null
0 vote
Dependency:
compile ":jabber:0.1"

 Documentation

Summary

Installation

grails install-plugin jabber

Description

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 are using it with Google Talk, you will 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!