I’m trying to get a working example, similar to the simple chat example in order to evaluate the SmartClient Real-Time Messaging. The JavaDocs don’t appear to include the classes noted in the messaging quick reference. For example, I’m sure I will need to extend the ISCMessageDispatcher, and a few other classes to get my prototype working. How can I get a hold of the JavaDocs for these classes (com.isomorphic.messaging), or the source of the server code for the simple chat example?
Hi gmccone -
Right - the javadocs don’t include these classes at the moment, but the Real-Time Messaging Quick Reference does include the public APIs and extension points of all the relevant classes.
The messaging example in the SDK (examples/messaging/simple_chat.jsp) does not require server-side code. It works with the built-in MessagingServlet, creating a “simple mode” dispatcher (com.isomorphic.messaging.LocalMessageDispatcher) via the configuration found in server.properties.
If you’re running in enterprise mode (using JMS) then you can send messages to browser-based subscribes by simply publishing messages to a topic named after a channel via standard JMS APIs. You can subscribe to browser messages by subscribing to a topic named after a channel, again via standard JMS APIs.
You can also send messages from the server, in either simple or enterprise mode, via e.g:
ISCMessageDispatcher messageDispatcher = ISCMessageDispatcher.instance();
// can also pass a List of channels. "myData" can be any Object
messageDispatcher.send(new ISCMessage("myChannel", "myData");
And you can also subscribe to a channel from the server like this:
ISCMessageDispatcher messageDispatcher = ISCMessageDispatcher.instance();
ISCSubscriber subscriber = new ISCSubscriber();
messageDispatcher.subscribe(subscriber, "myChannel");
while (true) {
int timeout = 1000;
// blocks until next message arrives, or timeout ms elapses
ISCMessage message = subscriber.nextMessage(timeout);
if (message != null) {
Object data = message.getData();
// do something with the message data...
}
}
data format in messaging module server API
Hi,
What is the data format of object in ISCMessage? Shall it implement serializable?
In smartGWT context, can a valid GWT object be sent/received over the network?
The “data” argument is translated to JavaScriptObjects by the same process as is documented for dsResponse/rpcResponse.data.
As far as SmartGWT, it does not use GWT-RPC or similar processes - the data arrive as JavaScriptObjects which you can then use JSOHelper APIs to turn into Records or other client-side objects.
Hi.
How about new ISCMessage(List arg0, Object arg1, String arg2)
what is String arg2? we should know those arg0 is for List of channel and arg1 for object to send.
i cannot find any information/API in Messaging_QuictRef.pdf (version 6.5). what was the purpose for that parameter used for?
currently i use the new ISCMessage(List arg0, Object arg1) and it works fine.
just wonder…
That signature of ISCMessage is for internal use only. Stick to the documented APIs.
ok. thanks!