hapijs

package
v0.0.0-...-9220275 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 1, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HapiJS

type HapiJS struct {
	// contains filtered or unexported fields
}

HapiJS provides JS callable methods to the Hub using a websocket connection to the Hub

func NewHubAPI

func NewHubAPI() *HapiJS

NewHubAPI returns a new HapiJS instance. connect() must be called first

func (*HapiJS) Connect

func (hapi *HapiJS) Connect(this js.Value, args []js.Value) interface{}

Connect to the Hub and create the gateway capnp client. Use login to authenticate. Note that auto-discovery must be handled on the JS side as nodejs doesn't allow DNS-SD through wasm. This returns a promise to avoid deadlock.

args[0] serviceID, also used as publisherID. Must match CN field in client cert
args[1] fullURL is the full websocket address, eg: wss://addr:port/ws
args[2] clientCertPem with client certificate for client authentication
args[3] clientKeyPem with client key for client authentication
args[4] caCertPem with CA's certificate for server authentication

func (*HapiJS) Disconnect

func (hapi *HapiJS) Disconnect()

Disconnect from the Hub

func (*HapiJS) Login

func (hapi *HapiJS) Login(this js.Value, args []js.Value) interface{}

Login is the async method to login to the gateway This is an alternate way to authenticate in case a client certificate is not available.

args[0] = loginID string args[1] = password string

func (*HapiJS) Ping

func (hapi *HapiJS) Ping(this js.Value, args []js.Value) interface{}

Ping is the async method to ping the gateway This does not require authentication.

func (*HapiJS) PubEvent

func (hapi *HapiJS) PubEvent(this js.Value, args []js.Value) interface{}

PubEvent Async method for publishing the events This obtains the service pubsub capability from the gateway and publishes the event. This capability is only available when using certificate authentication as it is intended for services.

args[0] = thingID args[1] = event name args[2] = event data serialized

func (*HapiJS) SubActions

func (hapi *HapiJS) SubActions(this js.Value, args []js.Value) interface{}

SubActions Async method for subscribing to all actions of a given thing, or all things. This obtains the service pubsub capability from the gateway and subscribes to actions. This capability is only available when using certificate authentication as it is intended for services.

args[0] = callback handler to invoke: (publisher ID, thingID, actionName, actionValue)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL