Saturday, 13 August 2016

Light Streamer Step by Step on windows

Lightstreamer(http://www.lightstreamer.com/) is a high-performance push/streaming engine based on the AJAX-Comet paradigm that delivers real-time textual data to Web browsers and to thick applications.

I found their documents all over the place so I decided to aggregate all the steps we need to follow in one place.


To test and see how lightstreamer wroks
1- download MODERATO from http://www.lightstreamer.com/download/
Lightstreamer Moderato edition can be used for free even in production environments and does not require any license key. http://www.lightstreamer.com/ls-features
2- unzip downloaded folder 
4- you need to copy lightstreamer.js from \ Lightstreamer\DOCS-SDKs\sdk_client_web_unified\lib  to \Lightstreamer-example-HelloWorld-client-javascript\src
5- edit  \Lightstreamer-example-HelloWorld-client-javascript\src\index.html and change 
     var client = new LightstreamerClient(null,"HELLOWORLD");
to
    var client = new LightstreamerClient("http://push.lightstreamer.com/", "HELLOWORLD");
6- open /Lightstreamer-example-HelloWorld-client-javascript/src/index.html in browser and you should be data getting updated 


 

As you see above, data get pushed from http://push.lightstreamer.com/ to our html page.
Light streamer server has two responsibilities 
1- host Adapters and get data from them 
2- Serve Clients and send data that adapters has been provided

An Adapter is a software component that connects Light streamer Server and provides data.
A Client connects and subscribe to Light streamer Server to get the real-time data.

How to Set Light streamer Server locally on windows 
1- You need a Java SE platform implementation installed on your system.
You can get the latest version from Oracle (you can choose either the
Server JRE or the JDK):

2- Open notepad in admin mode and open \Lightstreamer\bin\windows\LS.bat file and update the value of JAVA_HOME to location of your java sdk
set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_102

3- in command prompt go to the \Lightstreamer\bin\windows directory and execute
"Start_LS_as_Application.bat".

4- to verify your Light streamer server is working and is listening to tcp ports, browse http://localhost:8080

Now the Light streamer server is ready to host Adapters and Clients, stop service by entering Ctrl+C in command prompt to stop service

*Update client to point to our local server
1- edit  \Lightstreamer-example-HelloWorld-client-javascript\src\index.html and change 
var client = new LightstreamerClient("http://push.lightstreamer.com/", "HELLOWORLD");
to
var client = new LightstreamerClient("http://localhost:8080/", "PROXY_HELLOWORLD");

*Set .Net Adapter to send data to light streamer
2- copy ProxyHelloWorld  folder from \deploy\Deployment\Deployment_LS\ProxyHelloWorld and past it  to \Lightstreamer\adapters

*Run server and .net adapter and client
1- in command prompt go to the \Lightstreamer\bin\windows directory and execute "Start_LS_as_Application.bat".

2- in another command prompt window go to the \deploy\Deployment\Deployment_DotNet_Server   directory and execute “adapter_csharp.exe”
3- open /Lightstreamer-example-HelloWorld-client-javascript/src/index.html in browser and you should be data getting updated