Skip to content

wzr1337/node-opendds-rest-demo

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A Demonstration of using node-opendds to build a custom REST-to-DDS bridge

This is a very simple example of using node-opendds (the Node.js bindings for OpenDDS) in order to build a custom bridge between RESTful web services and DDS. The premise of this demo is based on a multiplayer game in which a single C++ 'control' application communicates using DDS with several Node.js 'server' bridge applications. Players may simply point a javascript capable browser at a running server (default port of 3210) in order to pull down a lightweight client web application in order to join the game.

The emphasis of this demo is to show how simple HTTP requests ('PUT', 'GET', 'DELETE') may be used to interact with DDS sample instances via a bridgine application, and as a result polling is used in order to get notifications of changes to game states. For real-world applications, this is obviously not ideal and some kind of asynchronous push notification (e.g. websockets) would most likely be used for the sake of performance and user experience.

Building the Demo

  • Set up the OpenDDS environment variables (DDS_ROOT, TAO_ROOT, ACE_ROOT etc)
  • Set up PATH / LD_LIBRARY_PATH to include OpenDDS, TAO, ACE, and MPC binaries
  cd <PathToOpenDDS>
  source sentenv.sh
  cd <pathToThisDemoRoot>
  1. Set up the environment variable DEMO_ROOT to point to the root of this repository
  export DEMO_ROOT=$(pwd)
  1. Generate project files using mwc. Assuming gnuace:
  mwc.pl -type gnuace node-opendds-rest-demo.mwc
  1. Build C++ IDL library and control application. Again, assuming 'gnuace':
  make depend && make
  1. Build Node.js server application
  cd server
  npm install
  cd -

Running the Demo

For this step, you'll likely want to spawn multiple consoles / terminals in order to run both the client and the server at the same time. Generally speaking, you hopefully shouldn't ever need to restart the control application.

Single Server

  1. Run the control application. Assuming some flavor of Linux/UNIX:
  export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/idl
  cd control
  ./control -DCPSPendingTimeout 3 -DCPSConfigFile ../rtps.ini
  1. Run the server application
  cd server
  npx ts-node main.ts -DCPSPendingTimeout 3 -DCPSConfigFile ../rtps.ini
  1. Navigate a javascript-enabled web browser to http://localhost:3210

Multiple Servers

Same as the steps above, though you will obviously need to launch multiple 'server' applications running on different ports (use the --port <PORT> option) as well as have multiple browser tabs open to connect to each of the servers.

Trouble Shooting

Error: Could not load node-opendds addon module

If you are experiencing the following error when starting the server,

Error: Could not load node-opendds addon module

make that the $PATH is containing all OpenDDS libs. It should look something like:

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/ubuntu/source/OpenDDS-3.22/ACE_wrappers/bin:/home/ubuntu/source/OpenDDS-3.22/bin

fix it by sourcing the OpenDDS setenv.sh script, e.g. source ../OpenDDS-3.2.2/setenv.sh

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 47.2%
  • TypeScript 31.2%
  • HTML 21.6%