Skip to content

Client library for connecting to a Furhat skill from a skill GUI

License

Notifications You must be signed in to change notification settings

FurhatRobotics/FurhatJSGUI

Repository files navigation

furhat-gui

Generated with nod NPM version Build Status Coverage Status

Client library for connecting to a Furhat skill from a skill GUI

Install

$ npm install --save furhat-gui

Usage

import FurhatGUI, { Furhat } from 'furhat-gui'

let furhat: Furhat = null

function setupSubscriptions () {
    furhat.subscribe('com.myapp.MyCustomEvent', (event) => {
        console.log('received event: ', event.event_name)
    })
}

FurhatGUI()
    .then(connection => {
        furhat = connection
        furhat.onConnectionError((_connection: WebSocket, ev: globalThis.Event) => {
            console.error("Error occured while connecting to Furhat skill")
        })
        furhat.onConnectionClose(() => {
            console.warn("Connection with Furhat skill has been closed")
        })
        setupSubscriptions()
    })
    .catch(console.error)

// Later somewhere in the code (after awaiting for the connection promise)
furhat.send({
    event_name: 'MyEvent',
    param1: 'MyParam1'
})

API

Table of Contents

FurhatGUI

FurhatGUI Function which sets up a connection to the furhat skill and gives the furhat object to send and recieve events to the skill.

Returns any Promise that will return the promise with a Furhat obkect

About

Client library for connecting to a Furhat skill from a skill GUI

Resources

License

Stars

Watchers

Forks

Packages

No packages published