public final class JabberMethods extends Object
Constructor and Description |
---|
JabberMethods(io.toro.martini.jabber.JabberConnectionManager esbJabberConnectionManager) |
Modifier and Type | Method and Description |
---|---|
static JabberConnection |
createJabberConnection(String name,
Map configuration)
Create a Jabber connection using the provided configuration.
|
static JabberConnection |
createJabberConnection(String name,
Map configuration,
groovy.lang.Closure closure)
Create a Jabber connection using the provided configuration.
|
static void |
jabber(String endpointName,
groovy.lang.Closure closure)
Invoke a closure which can operate on a provided
JabberConnection object. |
static void |
jabberChat(String endpointName,
String jid,
groovy.lang.Closure closure)
Invoke a closure which can operate on a provided
Chat object. |
static void |
jabberGroupchat(String endpointName,
String roomJID,
groovy.lang.Closure closure)
Invoke a closure which can operate on a provided
MultiUserChat object. |
static void |
sendGroupMessage(String endpointName,
String nickname,
String roomJID,
boolean leaveOnFinish,
String message)
Send a message to a chat room.
|
static void |
sendGroupMessage(String endpointName,
String nickname,
String password,
String roomJID,
boolean leaveOnFinish,
String message)
Send a message to a chatroom.
|
static void |
sendMessage(String endpointName,
String jid,
String message)
Send a message to a user.
|
@Autowired JabberMethods(io.toro.martini.jabber.JabberConnectionManager esbJabberConnectionManager)
public static void sendMessage(String endpointName, String jid, String message) throws ToroException
Send a message to a user. This will reuse the Jabber connection created by the endpoint. This one-liner requires the endpoint to be started.
Example usage:
'endpoint'.sendMessage( 'user@your.org', 'Hello, earthling!' )
endpointName
- the name of the endpoint belonging to the current packagemessage
- the message to sendjid
- the Jabber ID of the recipientToroException
public static void jabberChat(String endpointName, String jid, groovy.lang.Closure closure) throws ToroException
Invoke a closure which can operate on a provided Chat
object.
The Chat
object is constructed based on the provided JID,
and the Jabber connection created by the endpoint.
This one-liner requires the endpoint to be started.
Example usage:
'endpoint'.jabberChat('user@your.org') { chat -> chat.sendMessage('Hello, earthling!') }
endpointName
- the name of the endpoint belonging to the current packagejid
- the Jabber ID of the userclosure
- the closure to invokeToroException
public static void sendGroupMessage(String endpointName, String nickname, String roomJID, boolean leaveOnFinish, String message) throws ToroException
Send a message to a chat room. This will reuse the Jabber connection created by the endpoint. This one-liner requires the endpoint to be started.
Example usage:
'endpoint'.sendGroupMessage( 'NotAnAlien' , 'room@your.org' , true, 'Hello, earthlings!' )
endpointName
- the name of the endpoint belonging to the current packagenickname
- the name to use in the chat roomroomJID
- the Jabber ID of the chat roomleaveOnFinish
- determines whether or not to leave the chat room after message deliverymessage
- the message to sendToroException
public static void sendGroupMessage(String endpointName, String nickname, String password, String roomJID, boolean leaveOnFinish, String message) throws ToroException
Send a message to a chatroom. This will reuse the Jabber connection created by the endpoint. This one-liner requires the endpoint to be started.
Example usage:
'endpoint'.sendGroupMessage( 'NotAnAlien', 'room@your.org' , true, 'I can speak English.' )
endpointName
- the name of the endpoint belonging to the current packagenickname
- the name to use in the chat roompassword
- the password of the chat roomroomJID
- the Jabber ID of the chat roomleaveOnFinish
- determines whether or not to leave the chat room after message deliverymessage
- the message to sendToroException
public static void jabberGroupchat(String endpointName, String roomJID, groovy.lang.Closure closure) throws ToroException
Invoke a closure which can operate on a provided MultiUserChat
object.
The MultiUserChat
object is constructed based on the provided JID,
and the Jabber connection created by the endpoint.
This one-liner requires the endpoint to be started.
Example usage:
'endpoint'.jabberGroupchat( 'room@your.org' ) { chat -> chat.sendMessage( 'But can you do this?' ) }
endpointName
- the name of the endpoint belonging to the current packageroomJID
- the Jabber ID of the chat roomclosure
- the closure to invokeToroException
public static void jabber(String endpointName, groovy.lang.Closure closure) throws ToroException
Invoke a closure which can operate on a provided JabberConnection
object.
The JabberConnection
object is obtained from the named endpoint.
This one-liner requires the endpoint to be started.
The closure must avoid disconnecting the connection. To properly disconnect the connection, stop the endpoint instead. If the connection is closed, this one-liner will attempt to reconnect the connection.
Example usage:
'endpoint'.jabber() { connection -> connection.sendMessage( 'alien@not.earth', 'Why are you green?' ) }
endpointName
- the name of the endpoint belonging to the current packageclosure
- the closure to executeToroException
public static JabberConnection createJabberConnection(String name, Map configuration, groovy.lang.Closure closure) throws ToroException
Create a Jabber connection using the provided configuration.
Example usage:
def configuration = [ serviceName: 'service' , username: 'user@your.org', password: 'superS3CR3Tpa$$word' ] 'connection'.createJabberConnection( configuration ) { connection -> println "${connection.getName()}" }
name
- the name of the connection to be createdconfiguration
- configuration for the Jabber connectionclosure
- optional closure for executing more actions against the Jabber connection (eg. send a message)ToroException
JabberConnection.buildConfiguration(Map)
public static JabberConnection createJabberConnection(String name, Map configuration) throws ToroException
Create a Jabber connection using the provided configuration.
Example usage:
def configuration = [ serviceName: 'service' , username: 'user@your.org', password: 'superS3CR3Tpa$$word'] def connection = 'connection'.createJabberConnection( configuration )
name
- the name of the connection to be createdconfiguration
- configuration for the Jabber connectionToroException
JabberConnection.buildConfiguration(Map)
Copyright © 2021. All rights reserved.