Description
The Jabber plugin enables the usage of the XMPP protocol to communicate with Jabber servers. Relies on the Xmlrpc Plugin and the Smack/Smackx libraries.
Installation
The current version of griffon-jabber-plugin is 0.1
To install just issue the following command
griffon install-plugin jabber
Usage
The plugin will inject the following dynamic methods:
- XMPPConnection jabberConnect(Map params, Closure stmts) - connects to a Jabber server using the provided credentials
Where params may contain
| Property | Type | Required | Notes |
|---|---|---|---|
| serviceName | String | |
|
| host | String | |
|
| port | int | |
|
| username | String | |
|
| password | String | |
|
| proxy | Map | |
the following properties may be specified type: String. Any of HTTP, SOCKS4, SOCKS5 or NONE. Defaults to HTTP host: String. port: int. Defaults to 80 username: String. Default is empty. password: String. Default is empty. |
Any additional params will be set on org.jivesoftware.smack.ConnectionConfiguration directly.
A new method is added to XMPPConnection in order to establish a chat session and send messages
- chatWith(String participant, String message)
If you wish to listen for incoming messages then you'll need to add a closure property (or a method) with the following signature on the instance that established the Jabber connection
def onJabberMessage = { msg -> ... }
// or as a method
void onJabberMessage(msg) { ... }
The type of the msg argument is org.jivesoftware.smack.packet.Message
Examples
Connecting to Gtalk
class GtalkController {
def model
private conn
def connect = { evt = null ->
conn = jabberConnect(host: "talk.google.com", port: 5222i,
serviceName: "gmail.com",
username: model.username,
password: model.password)
}
def sendMessage = { evt = null ->
conn.chatWith(model.participant, model.message)
}
def onJabberMessage = { msg ->
model.chatText = "${msg.from} said: '${msg.body}'"
}
}
Configuration
Dynamic method injection
Dynamic methods will be added to controllers by default. You can change this setting by adding a configuration flag in Application.groovy
griffon.jabber.injectInto = ["controller", "service"]
History
| Version | Date | Notes |
|---|---|---|
| 0.1 | 10-26-09 | Initial release |
