Giter VIP home page Giter VIP logo

lightstreamer-example-quickstart-client-kotlin's Introduction

Lightstreamer - Quickstart Example - Kotlin Client

The Quickstart Example provides the source code to build very simple and basic client applications, used to test the capability of the Client APIs to connect and receive data from Lightstreamer Server. The examples can be used to familiarize with the Client APIs and as a reference on how to use them, and can be used as a starting point for client application implementations.

This project contains the Kotlin source files of the same sample applications, that shows how the Lightstreamer Java SE Client API can be used to connect to Lightstreamer Server.

Details

The Lightstreamer Java SE Client API is used to connect to Lightstreamer, subscribe to available items and to send messages to the server. Automatic reconnections and resubscriptions are offered out-of-the-box by the library itself. All the available methods are non-blocking so they execute fast, network and other time-consuming operations are handled on dedicated threads; methods are synchronized among themselves though, so calling many methods on the same instance from different threads at the same time might still slow down things a bit.

Dig the Code

Each source class (excluding the SystemOutClientListener) is an independent application with its own main() method. They generally connect to the server and perform a subscription, printing on the console the incoming Item Updates. Only PortfolioOrderEntry behaves differently, as it just submits a message and closes.

To resume, under src/quickstart you'll find:

  • SystemOutClientListener.kt is a simple implementation of the ClientListener interface that is used by the other examples. An instance of this class, listening to a LightstreamerClient instance (through the addListener method) will print on the standard output information about the status of the connection.
  • Stocklist.kt is a simple application that subscribes to 15 stocks (MERGE) and prints all the updates on the standard output
  • Portfolio.kt is very similar to the Stocklist.kt example, but, in this case a 2-level subscription, representing a portfolio (COMMAND) is shown. The second level is obtained using the same stock data (MERGE) used by the previous example.
  • Chat.kt is a simple application that subscribes to the chat item (DISTINCT) on a Lightstreamer server and then accepts command from the standard input to send messages, connect/disconnect subscribe/unsubscribe and others making it possible to easily experiment with the APIs
  • PortfolioOrderEntry.kt sends a message representing an order based on the program arguments, waits for the Server response, and prints it; then closes. The effect of the order submission can be seen by running Portfolio.kt concurrently.
  • Main.kt utility class for launch through Maven.

Screenshot

Build

To build and install a version of this demo you have two options: either use Maven (or other build tools) to take care of dependencies and building (recommended) or gather the necessary jars yourself and build it manually. For the sake of simplicity only the maven case is detailed here.

In both cases, if you plan to point the examples to your own server, you'll need to install the following adapters (depending on which quickstart example you want to run you might not need them all):

Follow the instructions on those projects to get them up and running (in the portfolio case, you'll need the full version).

Maven

You can easily build and run this application using Maven through the pom.xml file located in the root folder of this project. As an alternative, you can use an alternative build tool (e.g. Gradle, Ivy, etc.) by converting the provided pom.xml file.

Assuming Maven is installed and available in your path you can build the demo by running

mvn package

You can also run the application with the following command

mvn exec:java -Dexec.args="chat http://push.lightstreamer.com"

the arguments in the above command select the example to run (and must be either "chat", "stocklist", "portfolio", or "orderentry") and the target Lightstreamer server. Only for "orderentry", the command should also specify an item name supported by the Portfolio Data Adapter and a quantity (possibly negative), like in

mvn exec:java -Dexec.args="orderentry http://push.lightstreamer.com item1 100"

See Also

Lightstreamer Adapters Needed by This Client

Related Projects

Lightstreamer Compatibility Notes

  • Compatible with Lightstreamer Java SE Client SDK 5.0 or newer.
  • For Lightstreamer Server 7.4.0 or newer. Ensure that Java SE Client API is supported by Lightstreamer Server license configuration.
  • For a version of this example compatible with Lightstreamer Java Client API version 4.x, please refer to this tag.

lightstreamer-example-quickstart-client-kotlin's People

Contributors

dario-weswit avatar bravo27 avatar acarioni avatar weswit-team avatar

Stargazers

Rahul avatar Rafael Silvestre avatar Ibragimov Ruslan avatar

Watchers

James Cloos avatar Alessandro Alinone avatar  avatar  avatar Gianluca Finocchiaro avatar Francesco Vasco avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.