Lightstreamer Example Basic 2 Client Unity by Lightstreamer - 2

Games & ProjectsSDK

This project includes a demo client showing the integration between Lightstreamer server and the Unity 2017 development platform

Unity 2018.1.6f1Apache License 2.0Updated 1 year agoCreated on September 22nd, 2017
Go to source

Lightstreamer - Basic Demo - Unity Client

This project includes a demo client showing the integration between Lightstreamer server and the Unity 2017 Development platform.

Live Demo

Demo ScreenShot

View live demo

(for Windows systems: download; unzip it; launch BasicUnityDemo.exe)
(for Linux systems: download; unzip it; launch BasicUnityDemo.x86)
(for Android devices: download; unzip it; install BasicUnityDemo.apk manually on your Android device)


The demo intends to show a reference pattern for using .Net Standard Client API for Lightstreamer in a Unity 3d project in order to add sources of real-time information to which game objects in a scene can react. Specifically, the demo includes two cube 3D ojects that change their size and color according to the real-time information received through the StockList Data Adapter, the same of the StockList demo. In addition a 3D Text object acts as very very simple chat based on the Round-Trip demo.

All the objects who want to communicate with the Lightstreamer server should be children of the same parent object, in this demo called ‘World’, and be tagged with a label that starts with the string ‘lightstreamer’. To ‘World’ has been added the LighstreamerClientAsset component, which will take care of opening a Lightstreamer session with the information provided in the parameters: Push Url and Adapters Set.

All the child objects can ask to open a Subscription versus the Lightstreamer server by setting these parameters of the LighstreamerAsset component: ItemName, Schema, DataAdapter. The LightstreamerClientAsset component of the World object will perform all the subscriptions specified by child objects, and will communicate with them through two types of messages :

  • RTStatus - a message of this type provides information about the status of communication with the Lightstreamer server.
  • RTUpdates - this type of messages brings a ItemUpdate object of the Lightstreamer .NET clien library.

Dig the Code

The Lightstreamer bits in this demo are located inside C# scripts in the Assets/ directory.

In detail the files with the source code are:

  • LighstreamerClientAsset is the class that manages the connection to the Lightstreamer server and all the subscriptions. Redistributes received updates by broadcasting messages to all the child objects of the object game it is added.
  • LighstreamerAsset is a base class that should be extended by all those components who want to consume real time events from Lightstreamer server.
  • LightstreamerCubeAsset.cs is the Lightstreamer component, extension of LighstreamerAsset base class, that can be associated to a Cube object. Upon receipt of a message, after verifying that the involved Item is the one specified in the ItemName parameter, change the color of the cube by setting parameterized rgb values based on the value of the last_price field (I admit this does not make much sense, it’s just an example), and modify the cube size (y axis only) in pase to the pct_change field value.
  • LightstreamerMsgAsset.cs is the Lightstreamer component, extension of LighstreamerAsset base class, that can be associated to a 3D Text object to display the message of an Item of Round-Trip demo specified in ItemName parameter. In addition this class read the Input and sends the typed message to the server.
  • ConnectionListener.cs is the implementation of ClientListener interface to handle notifications of connection activity and errors.
  • TableListener.cs is the implementation of SubscriptionListener interface to handle notification of data updates and subscription termination.

Check out the sources for further explanations. The Lightstreamer Documentation is available at:

NOTE: Not all the functionalities of the .Net Standard Client API for Lightstreamer are exposed by the classes listed above. You can easily expand those functionalities using the Lightstreamer .NET Standard API as a reference.

For any inquiry, please email


If you want to install a version of this demo pointing to your local Lightstreamer Server, follow these steps:

<?xml version="1.0"?>

<!-- Mandatory. Define an Adapter Set and sets its unique ID. -->
  <adapters_conf id="DEMO">


        <!-- Optional for RoundTripMetadataAdapter.
               Configuration file for the Adapter's own logging.
               Logging is managed through log4j. -->
        <param name="log_config">adapters_log_conf.xml</param>
        <param name="log_config_refresh_seconds">10</param>

        <!-- Optional, managed by the inherited LiteralBasedProvider.
               See LiteralBasedProvider javadoc. -->
        <param name="max_bandwidth">40</param>
        <param name="max_frequency">3</param>
        <param name="buffer_size">30</param>
        <param name="prefilter_frequency">5</param>
        <param name="allowed_users">user123,user456</param>
        <param name="distinct_snapshot_length">30</param>

        <!-- Optional, managed by the inherited LiteralBasedProvider.
               See LiteralBasedProvider javadoc. -->
        <param name="item_family_1">roundtrip\d{1,2}</param>
        <param name="modes_for_item_family_1">MERGE</param>
        <param name="item_family_2">item.*</param>
        <param name="modes_for_item_family_2">MERGE</param>


    <!-- Mandatory. Define the Data Adapter. -->
    <data_provider name="ROUNDTRIP_ADAPTER">



	<!-- Mandatory. Define the Data Adapter. -->
	<data_provider name="QUOTE_ADAPTER">


		<!-- Mandatory. Java class name of the adapter. -->


  • Launch Lightstreamer Server.
  • Download the file, which you can find in the deploy release of this project and extract the BasicUnityDemo folder.
  • Launch BasicUnityDemo.exe (please note that the demo tries to connect to http://localhost:8080).


To build your own version of UnityDemo.exe, instead of using the one provided in the file from the Install section above, follow these steps:

  • A Unity 2018 Development platform must be installed to build and run this demo. Download and Install Unity 3D from:
  • Clone this project: > git clone
  • Get the binaries files of the library (Lightstreamer_DotNet_Standard_Client.dll) and all dependecies from NuGet Lightstreamer.DotNetStandard.Client version 5.0.0 or higher and put them in the Assets\LightstreamerClient new folder; then import it as a new Asset.
  • Open SndScene.unity file in Asset subfolder double clicking on it. The Unity Development Environment should open.
  • You can then build and run the project by menu File and then Build & Run.
  • Please note that in the inspector of the World object you can choose the Lightstreamer server targeted by the demo; you can change the Push Url parameter to ‘http://localhost:8080’ or ‘’ depending you want to use your local instance of Lightstremaer server or our public installations.

See Also

Lightstreamer Adapters Needed by This Demo Client

Lightstreamer Compatibility Notes

  • Compatible with Lightstreamer .NET Standard Client Library version 5.0.0 or newer.
  • For Lightstreamer Server version 7.0 or greater. Ensure that .NET Standard Client API is supported by Lightstreamer Server license configuration.
Show all projects by Lightstreamer