This project includes the resources needed to develop the Metadata and Data Adapters for the Room-Ball Demo that is pluggable into Lightstreamer Server.
The Room-Ball Demo implements a simple pure Server-side Mode multiplayer soccer game:
- Physics runs on server side only
- User commands are streamed from clients to server
- Position updates are streamed from server to clients
- Clients are pure renderers (no feedback, no prediction, no interpolation)
For more information, see this slide deck from the HTML5 Developer Conference:
http://www.slideshare.net/alinone/slides-html5-devconf-20131022
The project is comprised of source code and a deployment example.
A Java Adapter implementing both the SmartDataProvider interface and the MetadataProviderAdapter interface, to inject data into Lightstreamer server with real-time information about the movement of every player in the room. The adapter accepts also message submission for the chat room.
The adapter receives input commands from Lightstreamer server, which forwards messages arrived from clients to the adapter in relation to:
- Movement commands;
- Changing last message for the player.
The Metadata Adapter inherits from the reusable LiteralBasedProvider and just adds a simple support for message submission. It should not be used as a reference, as no guaranteed delivery and no clustering support is shown.
This Adapter Set is configured and will be referenced by the clients as ROOMBALL
.
The adapters.xml
file for the Room-Ball Demo, should look like:
<?xml version="1.0"?>
<adapters_conf id="ROOMBALL">
<metadata_adapter_initialised_first>Y</metadata_adapter_initialised_first>
<metadata_provider>
<adapter_class>com.lightstreamer.examples.roomball_demo.adapters.RoomBallMetaAdapter</adapter_class>
<!--
TCP port on which Sun/Oracle's JMXMP connector will be
listening.
-->
<param name="jmxPort">9999</param>
<!--
Dimensions of the world.
Any changes to these parameters involves actions on the client
side for the drawing of the room.
-->
<param name="world_size_x">1000</param>
<param name="world_size_y">550</param>
</metadata_provider>
<data_provider>
<adapter_class>com.lightstreamer.examples.roomball_demo.adapters.RoomBallAdapter</adapter_class>
<!--
Frame rate for physics calculations. In milliseconds.
-->
<param name="frameRate">10</param>
<!--
Number of steps for a single frame
-->
<param name="stepsPerFrame">4</param>
</data_provider>
</adapters_conf>
Note that the parameter <metadata_adapter_initialised_first>
is mandatory to be set to Y to allow proper initialization of Metadata and Data Adapters respectively.
NOTE: not all configuration options of an Adapter Set are exposed by the file suggested above.
You can easily expand your configurations using the generic template, see the Java In-Process Adapter Interface Project for details.
Please refer here for more details about Lightstreamer Adapters.
If you want to install a version of the Room-Ball Demo in your local Lightstreamer Server, follow these steps:
- Download Lightstreamer Server (Lightstreamer Server comes with a free non-expiring demo license for 20 connected users) from Lightstreamer Download page, and install it, as explained in the
GETTING_STARTED.TXT
file in the installation home directory. - Make sure that Lightstreamer Server is not running.
- Get the
deploy.zip
file of the proper release, unzip it, and copy theRoomBall
folder into theadapters
folder of your Lightstreamer Server installation. - [Optional] Customize the logging settings in log4j configuration file
RoomBall/classes/log4j2.xml
. - Launch Lightstreamer Server.
- Test the Adapter, launching the Lightstreamer - Room-Ball Demo - HTML Client listed in Clients Using This Adapter.
To build your own version of roomball-adapter-java-x.y.z.jar
instead of using the one provided in the deploy.zip
file from the Install section above, 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.
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 install dependency:copy-dependencies
- LiteralBasedProvider Metadata Adapter
- Lightstreamer - 3D World Demo - Java Adapter
- Lightstreamer - 3D World Demo - Three.js Client
- Compatible with Lightstreamer SDK for Java In-Process Adapters since version 8.0.
- For a version of this example compatible with Lightstreamer SDK for Java Adapters versions 7.4.x, please refer to this tag.
- For a version of this example compatible with Lightstreamer SDK for Java Adapters versions 7.0 to 7.3, please refer to this tag.
- For a version of this example compatible with Lightstreamer SDK for Java Adapters version 6.0, please refer to this tag.
- For a version of this example compatible with Lightstreamer SDK for Java Adapters version 5.1, please refer to this tag.