Jet Link Simulations

Jet Link Simulations

  • Docs
  • API Reference
  • Help

›Guides

Getting Started

  • Home
  • Installation
  • The Basics
  • Developer Guidelines

Guides

  • Create a New Application
  • Sending & Receiving Data

API Reference

  • Introduction to API
  • Actuators
  • Core
  • Elements
  • Engines
  • Events
  • Loaders
  • Utilities

Sending & Receiving Data

This guide aims to help you understand how data is exchanged between the flight simulator and the web app.

Prerequisites

  • JLS_JetBridge
  • JLS API > DataStreamClient

Setting up X-Plane

// TODO: add to docs

Setting up the Server

// TODO: add to docs

Setting up the Client

  1. Create a new instance of JLS.loaders.DataStreamClient, specifying the ip and any options (if required).

    const xpDataClient = new DataStreamClient('127.0.0.1', {
        port: 8585,
        socketType: 'io',
        autoConnect: false,
    })
    
  2. Register the required datarefs for this screen

    xpDataClient.registerDataRefs([
        'jetlink/rj45...',
        'jetlink/rj45...',
        'jetlink/rj45...',
        'jetlink/rj45...',
        'jetlink/rj45...',
        'jetlink/rj45...',
        'jetlink/rj45...',
        'jetlink/rj45...',
    ])
    
  1. Set the main data client to use as the globally shared. This allows you have different data coming from more than one source and set the main client at anytime. This can be helpful for using the same app for many flight simulations or having a "back-up" data source if the initial client fails.

    DataStreamClient.setShared(xpDataClient)
    
  1. That's it! The client is now receiving data. Each time data is received, the client's onMessage event is fired and can be used for any purpose. To bind an animating element to a dataref set it's dataRef value.

    const engine1_oilPress_Pointer = new PointerElement({
        ...
        dataRef: 'jetlink/rj45...',
        ...
    })
    

JSON Schema

The DataStreamClient returns an array of objects. Each object includes a dataRef which is of type string and a dataValue with the type of data (generally a string, float, int).

Expected data format received from JLS JetBridge

[
    {
        "dataRef": "jetlink/rj45...",
        "dataValue": 98.42
    },
    {
        "dataRef": "jetlink/rj45...",
        "dataValue": 1
    },
    {
        "dataRef": "jetlink/rj45...",
        "dataValue": "OFF"
    }
]

The JetBridge expects an array of objects with dataCommand being a string of the X-Plane dataref to change along with a dataValue (generally a string, float, int).

Expected data format to send commands to JLS JetBridge

[
    {
    "dataCommand": "jetlink/rj45...",
    "dataValue": "OFF"
    }
]
← Create a New ApplicationIntroduction to API →
  • Prerequisites
  • Setting up X-Plane
  • Setting up the Server
  • Setting up the Client
    • JSON Schema
Jet Link Simulations
Docs
Getting StartedGuidesAPI Reference
Community
User ShowcaseStack OverflowProject ChatTwitter
More
BlogGitHub
Copyright © 2020 Name or Your Company Name