Lightstreamer Web Client 7.0.4 API Reference

This JavaScript library enables any JavaScript application running in a web browser to communicate bidirectionally with the Lightstreamer Server. A different library, specific for Node.js, is available on NPM. The API allows to subscribe to real-time data pushed by the server, to display such data, and to send any message to the server. The library can be used with two different approaches: leveraging an AMD loader or in the old fashioned way through global variables. The library is distributed in its complete form in the AMD-oriented format. It is recommended to load the generator.html file distributed with the library to prepare a custom library that contains only the needed bits and in the preferred format. The generator will also show how and which files to include and how to reference the included classes.

Start digging into the API from the LightstreamerClient object.

When running in a browser window some limitation may apply:
  • On the non-webkit versions of Opera and on older versions of other browsers (IE<=7, FX<=3) both Ligthtstreamer server and the Web Server which supplies the front-end pages must share a common domain for the streaming to work; so, as an example, if the web server is www.mycompany.com and the Lightstreamer server is push.mycompany.com the following code is needed:
    document.domain="mycompany.com";
    Note that, as a consequence, you may need to set the document.domain in other front-end pages too, in order to allow them to interoperate with pages that have their document.domain set.
    Further details and special cases can be found in the "Additional notes" section of the "Lightstreamer JS Client - Deployment Config Matrix" document.
  • On the non-webkit versions of Opera and on older versions of other browsers (IE<=7, FX<=2) if an HTML "A" element is used to run javascript code, then the href="javascript:myStuff()" syntax should not be used, as it may cause the streaming connection to be stopped. The href="#" onClick="myStuff(); return false;" syntax should be used, instead.
    Note the final "return false;" statement, which prevents the execution of the default event handler. If missing, the browser may change the displayed address by adding "/#"; some browsers (e.g. Firefox) may even add a spurious entry in the history list.
    Anyway remember that you can also associate onclick events to elements other than "A" avoiding the problem altogether.
  • Some browsers are permitted to open a limited number of concurrent HTTP connections per server. If the front-end is composed by different html pages (or one single html page using different LightstreamerClient instances), each one with the need to get data from the same Lightstreamer server, you may want them to share the same connection to avoid saturating the connection pool. You can leverage the connectionSharing property of your LightstreamerClient instance to make various LightstreamerClient share the connection.
  • On IE6 if a page contains a LightstreamerClient instance, then it cannot be used as a link target or referred to in a "window.open" command, because, even in case the link is meant to preserve the page (i.e. to access it without replacing it, as in "myPage.html#position") this may stop the streaming connection.
  • Other common issues can find a solution on our public forum.

The library can also be used inside a Web Worker (excluding non-webkit Opera versions). The library generator highlights which class can or can't be used on such environment.
The sources of some of the classes of this library are available on GitHub. See details here
Check out the available examples and associated README to learn more

Note the following documentation convention:
Function arguments qualified as <optional> can be omitted only if not followed by further arguments. In some cases, arguments that can be omitted (subject to the same restriction) may not be qualified as <optional>, but their optionality will be clear from the description.