Lightstreamer - Bandwidth and Frequency Demo - HTML Client
This project includes a special version of Lightstreamer - Stock-List Demos - HTML Clients that demonstrates two important features of Lightstreamer: bandwidth management and frequency management.
Use the Max Bandwidth slider to dynamically change the maximum bandwidth granted for the current session. The client will notify the server of the new bandwidth and the server will change the update frequency on the fly, to respect the bandwidth limit.
You can see that with a bandwidth as ridiculous as 0.5 kilobits per seconds, Lightstreamer is still able to deliver updates to the page, thanks to the very optimized network protocol used.
Use the Max Frequency slider to dynamically change the maximum update rate of each item in the Subscription. The client will notify the server of the new frequency limit and the server will change the update frequency on the fly, to respect the frequency limit.
You can see how the bandwidth and frequency constraints act on different levels. The bandwidth constraint is applied to the whole session, that is, to the global update flow for this page. On the other hand, the frequency constraint is applied to each row (Item) individually. Both the constraints set an upper bound, which is dynamically managed by Lightstreamer Server.
Note that, thanks to MERGE mode, the updates are not queued and delayed, but resampled and conflated. In other words, when an item has a chance to be updated (based on a round-robin algorithm), it will receive the very latest state available, not an old one.
Click on the link under the table (Next/Previous 15) to dynamically switch between two lists of fifteen items and see how the initial snapshot is loaded, still respecting the bandwidth limit.
The demo includes the following client-side functionalities:
- Two Subscriptions containing 15 items each, subscribed to in MERGE mode, feeding a DynaGrid alternately, according to the selected list.
If you want to install a version of this demo pointing to your local Lightstreamer Server, follow these steps:
- Note that, as prerequisite, the Lightstreamer - Stock- List Demo - Java Adapter has to be deployed on your local Lightstreamer Server instance. Please check out that project and follow the installation instructions provided with it.
- Launch Lightstreamer Server.
- Get the
lightstreamer.min.jsfile from npm or unpkg and put it in the
src/jsfolder of the demo (if that is the case, please create it). Alternatively, you can generate a customized
lightstreamer.min.jslibrary containing only the classes you actually use; see the build instructions on the GitHub page. In that case, be sure to include the LightstreamerClient, Subscription, DynaGrid, ConnectionSharing, and StatusWidget modules.
- Get the
require.jsfile form requirejs.org and put it in the
src/jsfolder of the demo.
- Get the zip file from script.aculo.us and put the
slider.jsfiles in the
src/js/scriptaculousfolder of the demo.
You can deploy this demo to use the Lightstreamer server as Web server or in any external Web Server you are running.
If you choose the former case, please create the folders
<LS_HOME>/pages/demos/BandwidthDemo then copy here the contents of the
src folder of this project.
The client demo configuration assumes that Lightstreamer Server, Lightstreamer Adapters, and this client are launched on the same machine. If you need to target a different Lightstreamer server, please search this line:
var lsClient = new LightstreamerClient(protocolToUse+"//localhost:"+portToUse,"DEMO");
lsClient.js and change it accordingly.
The demo is now ready to be launched.
The html application can be optionally built, to reduce the number and size of the files to be downloaded by the browser, using r.js. A ready-made configuration file for the build process of the demo is available in the
build_r.js folder of this project.
The build is configured to use Google Closure compiler to minify the files. To run it as-is, you need to download rhino
compiler.jar from the closure compiler project, and
r.js from RequireJS. You also need a Java Virtual Machine installed on your system.
Once ready, from the
build_r.js folder, run
Lightstreamer Adapters Needed by These Demo Clients
- Lightstreamer - Stock-List Demo - Java Adapter
- Lightstreamer - Reusable Metadata Adapters - Java Adapter
- Lightstreamer - Stock-List Demos - HTML Clients
- Lightstreamer - Basic Stock-List Demo - jQuery (jqGrid) Client
- Lightstreamer - Stock-List Demo - Dojo Toolkit Client
- Lightstreamer - Stock-List Demos - Flex Clients
- Lightstreamer - Basic Stock-List Demo - Java SE (Swing) Client
- Lightstreamer - Basic Stock-List Demo - .NET Client
Lightstreamer Compatibility Notes
Compatible with Lightstreamer Web Client library version 8.0 or newer.
For a version of this example compatible with Lightstreamer SDK for Web Clients version 7.x or earlier, please refer to this tag.