
gwt-comet-streamhub
http://www.stream-hub.com/demo/gwt-comet-visualization-api/stock-visualization-demo.html'>http://www.stream-hub.com/images/gwt-demo-screenshot.png' />
Project Description
A GWT Module for using Comet with StreamHub.
What is StreamHub?
StreamHub is a Reverse Ajax & Comet server written in Java. A free Community Edition is available. For more details and to download it, visit the website: StreamHub - The Reverse Ajax & Comet Server.
Javadoc
Quick Start: Using the module in GWT
Add the following to your GWT module ( the .gwt.xml file):
<inherits name="com.google.gwt.json.JSON" />
<inherits name="com.streamhub.StreamHubGWTAdapter" />
Add the following JAR to the classpath:
streamhub-gwt-adapter-1.0.4.jar
Download the latest version of StreamHub and add the streamhub-min.js file to your HTML host page:
<script type="text/javascript" src="streamhub-min.js"></script>
Now you're ready to go. To connect use the following code:
StreamHubGWTAdapter streamhub = new StreamHubGWTAdapter();
streamhub.connect("${server.url}");
To subscribe you'll need to create a class which implements StreamHubGWTUpdateListener. For example:
public class StockListener implements StreamHubGWTUpdateListener {
public void onUpdate(String topic, JSONObject update) {
String lastPrice = ((JSONString)update.get("LastPrice")).stringValue();
String companyName = ((JSONString)update.get("Company")).stringValue();
String percentChange = ((JSONString)update.get("PercentChange")).stringValue();
String change = ((JSONString)update.get("Change")).stringValue();
}
}
Then call subscribe on the adapter passing through the topic and your listener:
streamhub.subscribe("GOOG", new StockListener());
IMPORTANT: Working in hosted mode and compiled mode
As of version 1.0.3 and greater, the GWT Comet Adapter only works in compiled mode. We are working with the GWT team to produce a working hosted mode in future versions.
If you are using an older version, you may still be able to get it working in hosted mode by removing the cross-site linker:
<!-- Cross-site linker needed for compiling to web mode - remove during development in hosted mode -->
<add-linker name="xs" />
Examples and Demos
There are two GWT examples available to view on the StreamHub Examples page. The source for the adapter and the examples is available via the Source tab.
An Ext GWT demo is available in the StreamHub SDK version 2.0.10 and greater. Visit the StreamHub download page to get the latest version of the SDK. The source for the Ext GWT demo is available under the Source tab and is located at trunk/ExtGwtApp
.
Troubleshooting and bug reports
Please report any problems on the Issues tab by creating a new issue. Otherwise they won't get fixed.
Project Information
- License: MIT License
- 26 stars
- svn-based source control