FastX Client Api


Setup

You can programmatically send input to the remote session using the FastX Client Api. This is useful for integrators who need fine grained access to to FastX connection. Typical use cases include forcing default settings on a client, or building your own GUI interface.

Accessing the API

Add the following line in your HTML header

<script src='tools/client-api.js'></script>

Using the API

The header adds the FastX class to your global namespace.

<script>
    var myIframe = document.getElementById('fastxIframe');
    var fx = new FastX(myIframe);
    fx.onready = function(e) {
         fx.resize(window.innerWidth, window.innerHeight)
    }
</script>

Api Callbacks

onmessage(e)

Emitted when any message gets sent.

onready(e)

Emitted when the protocol has finished its initial setup.

Api Commands

send(msg: string, body: object)

Generic function that will send arbitrary messages to the iframe. Typically not used

resize(width: number, height: number)

Send a resize request

keyboard(layout: number, type: number)

Change the keyboard layout. Refer to https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/windows-language-pack-default-values for valid keyboard layouts

networkAutodetect(enabled: boolean)

Enable network autodetection

compression(current: number, min: number, max: number)

Set compression level (lower is blurrier)

frameRate(current: number, min: number, max: number)

Set the frame rate

frameWindow(current: number, min: number, max: number)

Set the number of interim frames before the server stops sending data

scaling(current: number, autoscale: boolean min: number, max: number)

Set the client side scaling. Autoscale lets the client determine it for you

mouseDown(flags: number, pos: Array<number:number>)

Send a mouse down event. Refer to https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons for flags. pos is an array of [x,y]

mouseUp(flags, pos)

Send a mouse up event. Refer to https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons for flags. pos is an array of [x,y]

mouseMove(pos)

Send a mouse move event. pos is an array of [x,y]

mouseWheel(delta, pos)

Send a mouse wheel. Negative delta is scroll up pos is an array of [x,y]

keyDown(code)

Send a keyboard down event. Refer to the code strings at https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code/code_values for a list of code values

keyUp(code)

Send a keyboard up event. Refer to the code strings at https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code/code_values for a list of code values

keyPress(code)

Shortcut for
fx.keyDown(code);
fx.keyUp(code);