public class Messaging
extends java.lang.Object
To use this class, you will need to inherit RealtimeMessaging
or
RealtimeMessagingNoScript
from the messaging.jar
(required for client side functionality only), and include the isomorphic_messaging
and isomorphic_js_parser
jar files for deployment on the server.
See the Messaging Quick Reference PDF file for more information on the optional Messaging module.
Constructor and Description |
---|
Messaging() |
Modifier and Type | Method and Description |
---|---|
static boolean |
connected()
Returns true if we are currently connected to any channels.
|
static void |
disconnect()
disconnect from all channels
|
static int |
getConnectTimeout() |
static java.lang.String |
getMessagingURL()
Get the URL of the messaging servlet.
|
static java.lang.String[] |
getSubscribedChannels()
Returns list of channels that we're currently subscribed to.
|
static boolean |
messagingLoaded()
Static method indicating whether the optional RealtimeMessaging module is loaded for the page.
|
static void |
send(java.lang.String[] channels,
java.lang.Object data,
RPCCallback callback)
Actually send data to a list of channels.
|
static void |
send(java.lang.String channel,
java.lang.Object data,
RPCCallback callback)
Actually send data to a channel.
|
static void |
setConnectTimeout(int timeout)
Specifies how long we wait for the handshake to the server to complete, before trying again.
|
static void |
setMessagingURL(java.lang.String URL)
Set the url of the messaging servlet.
|
static void |
subscribe(java.lang.String channel,
MessagingCallback callback)
Call to subscribe to channel.
|
static void |
unsubscribe(java.lang.String channel)
call to unsubscribe from channel(s).
|
public static void setMessagingURL(java.lang.String URL)
URL
- May be prefixed with [ISOMORPHIC] to use the isomorphicDirpublic static java.lang.String getMessagingURL()
public static void setConnectTimeout(int timeout)
timeout
- in mspublic static int getConnectTimeout()
public static void send(java.lang.String[] channels, java.lang.Object data, RPCCallback callback)
Note that the data is of type Object - typically this will be just a String. To send a complex data type such as a Map to the server, use the JSOHelper utility to get a JavaScript equivalent and pass in the JavaScriptObject.
channels
- data
- callback
- public static void send(java.lang.String channel, java.lang.Object data, RPCCallback callback)
Note that the data is of type Object - typically this will be just a String. To send a complex data type such as a Map to the server, use the JSOHelper utility to get a JavaScript equivalent and pass in the JavaScriptObject.
channels
- data
- callback
- public static java.lang.String[] getSubscribedChannels()
public static void subscribe(java.lang.String channel, MessagingCallback callback)
channel
- name of the channel we are subscribing to.callback
- this will execute whenever data is received from the server on this messaging channel.public static void unsubscribe(java.lang.String channel)
channel
- public static boolean connected()
public static void disconnect()
public static boolean messagingLoaded()