Jet Link Simulations

Jet Link Simulations

  • Docs
  • API Reference
  • Help

DataStreamClient

This client handles communication between the sandyApps and the JLS JetBridge. It can be used with the native WebSocketAPI (default) or with the socket.io library.

JLS.loaders.DataStreamClient

new DataStreamClient(ip, options)

    // Implementation example - shorten for brevity
    import { DataStreamClient } from 'path/to/loaders'

    
    const xplaneDataClient          = new DataStreamClient(127.0.0.1, {
                                    port: 8585,
                                    socketType: 'native',
    });


    DataStreamClient.setShared(xplaneDataClient) // Use this instance of a data client for grabbing data

    // Optionally listen for various events
    JLS.DataStreamClient.shared
        .onConnectionSuccess(() => {
            // do something
        })
        .onMessage(() => {
            // do something
        })
        .onDisconnect(() => {
            // do something, perhaps show an error on screen
        })

options

The word "options" is used somewhat loosely here as most of the fields are required. Actual optional parameters will have an optional flag.

NameTypeDefaultDescription
directoriesobject{ images: 'images', sounds: 'sounds' }optional The path to store each type of asset.

Members

ip

The ip of the host to connect to.

port

The port of the host to connect to.

socket

A reference to the socket connection.

socketType

The type of socket that the client is using.

autoConnect

Whether to connect to the host automatically.

hasStarted

A convience method to determine if the client has started and is receiving data.

registeredDataRefs

A directory / list of all the registered datarefs the client is listening for.

data

The data the client receives.

shared

The instance of the shared data client.

Methods

setShared(obj)

Sets the shared instance given a instantiated DataStreamClient object.

parameters

NameTypeDefaultDescription
objobject---The instance of the data stream client

registerDataRefs(dataRefArray)

Registers a dataref. The dataRefArray is a array of strings that you would like to subscribe to. Each string in the array is simply a key/id. In the context of XPlane, it is the actual dataRef.

parameters

NameTypeDefaultDescription
dataRefArrayarray---An array of strings that are datarefs. Easiest way to get all data refs needed is to use theJLS.Screen.getAllDataRefs method.

getRegisteredDataRefs()

Returns the registered datarefs.

getDataValue(dataRef)

Returns the dataref's value.

parameters

NameTypeDefaultDescription
dataRefstring---The data ref to get the value of.

getAll()

Gets all datarefs along with their current value. Will return empty array if no data is being received. For get a list of current registered datarefs. Use the getRegisteredDataRefs.

sendData(data, channel)

Sends socket data over the socket connection.

parameters

NameTypeDefaultDescription
data{any}---The data to send
channelstringmessageoptional The channel to emit the message to. Especially useful for discrete messages on different channels when using socket.io

update(id, value)

Convience function to update the globally stored data. May also simply set directly like so: this.data[*] = *

NameTypeDefaultDescription
idstring---The data ref
value{any}---The value to set for this data ref

connect()

Connects to the socket connection.

disconnect()

Disconnects the socket connection.

init()

Called from the constructor function, this calls other functions to "initialize" or setup the class.

  • new DataStreamClient(ip, options)
  • Members
    • ip
    • port
    • socket
    • socketType
    • autoConnect
    • hasStarted
    • registeredDataRefs
    • data
    • shared
  • Methods
    • setShared(obj)
    • registerDataRefs(dataRefArray)
    • getRegisteredDataRefs()
    • getDataValue(dataRef)
    • getAll()
    • sendData(data, channel)
    • update(id, value)
    • connect()
    • disconnect()
    • init()
Jet Link Simulations
Docs
Getting StartedGuidesAPI Reference
Community
User ShowcaseStack OverflowProject ChatTwitter
More
BlogGitHubStar
Copyright © 2020 Name or Your Company Name