Skip to content

Latest commit

 

History

History
466 lines (309 loc) · 12.9 KB

DOCS.md

File metadata and controls

466 lines (309 loc) · 12.9 KB

yarn run v1.22.17 $ jsdoc2md --separators --configure ./jsdoc2md.json --heading-depth 3 ./src/index.ts

Classes

Client

A class representing a HappyPanda X client

ServerErrorError

Base class for all server errors

Members

ServerErrorServerError

Base class for all authentication errors

AuthErrorAuthError

Wrong credentials error

AuthWrongCredentialsErrorAuthError

Authentication required error

AuthRequiredErrorAuthError

Missing credentials error

AuthMissingCredentialsServerError

Base class for all client errors

ClientErrorClientError

Timeout error

TimeoutErrorClientError

Base class for all connection errors

ConnectionErrorConnectionError

Server disconnect error

Constants

log

The logger

Functions

finalize(msg_dict, session_id, name, error, opts, msg_id)ServerMsg | string | Buffer

A helper function that will wrap your message up like this:

msg = {
     'session': session_id,
     'name': name,
     'data': data, # <--- your message is put here
  }

Client

A class representing a HappyPanda X client

Kind: global class


new Client(params)

Param Type Default Description
params Object

optional params

[params.name] string "js-client"

name of client

[params.host] string

server host

[params.port] integer

server port

[params.user] string

username

[params.password] string

password

[params.session_id] string

a server session id

[params.timeout] integer

connection timeout


client.timeout ⇒ number

Get the timeout value

Kind: instance property of Client


client.on(event, listener) ⇒ Client

Add a listener to the underlying socket

Kind: instance method of Client

Param Type Description
event string

event name

listener function

listener function


client.once(event, listener) ⇒ Client

Add a listener to the underlying socket

Kind: instance method of Client

Param Type Description
event string

event name

listener function

listener function


client.off(event, listener) ⇒ Client

Remove a listener from the underlying socket

Kind: instance method of Client

Param Type Description
event string

event name

listener function

listener function


client.alive() ⇒ boolean

Check if server is still alive

Kind: instance method of Client


client.ready() ⇒ boolean

Check if client is ready to exchange messages with server

Kind: instance method of Client


client.set_server(host, port)

Set server address

Kind: instance method of Client

Param Type Description
host string

server host

port integer

server port


client.is_connected() ⇒ boolean

Check if the client is still connected to the server

Kind: instance method of Client


client.close() ⇒ Promise

Close the connection

Kind: instance method of Client


client.handshake(params) ⇒ Promise

Perfom a handshake with the HPX server

Kind: instance method of Client
Category: async
Throws:

Param Type Description
params object

optinal params

[params.user] string

username

[params.password] integer

password

[params.ignore_err] boolean

ignore error


client.request_auth(ignore_err) ⇒ Promise

Forces client to request a new handshake, but doesn't invalidate previous session

Kind: instance method of Client
Category: async

Param Type Description
ignore_err boolean

ignore error


client.drop_auth(ignore_err) ⇒ Promise

Logout and invalidates the session

Kind: instance method of Client
Category: async

Param Type Description
ignore_err boolean

ignore error


client.connect(params) ⇒ Promise

Connect to HPX server

Kind: instance method of Client
Category: async

Param Type Description
params object

optional params

[params.host] string

server host

[params.port] integer

server port


client.send(msg) ⇒ Promise

Like [send_raw](send_raw), but as a convenience, this method will wrap your message into the required message structure HPX expects and automatically sets the session and name

Kind: instance method of Client
Category: async
Fullfil: Object - message from server

Param Type Description
msg Array

this is an array of Object's


client.send_raw(msg) ⇒ Promise

Send json-compatible Object to server. Receive json-compatible Object from server.

Note that this method will not modify your message and expects you to add the name and session yourself. See the [finalize](#finalize) function.

Kind: instance method of Client
Category: async
Fullfil: Object - message from server

Param Type Description
msg Object

message to send to the server


log

The logger

Kind: global constant
Group: Logging


log.enabled

Enable or disable logging

Kind: static property of log


log.logger

Can be set to a custom logger that will be used instead of console

Kind: static property of log


finalize(msg_dict, session_id, name, error, opts, msg_id) ⇒ ServerMsg | string | Buffer

A helper function that will wrap your message up like this:

msg = {
     'session': session_id,
     'name': name,
     'data': data, # <--- your message is put here
  }

Kind: global function

Param Type Description
msg_dict AnyJson

message to wrap

session_id string

optional, session id

name string

name of client

error ServerError

error message object to include in the final message

opts Object

optional options

[opts.to_json] boolean

convert the final message to json string

[opts.to_bytes] boolean

convert the final message to bytes buffer

msg_id AnyJson

optional message id


ServerError ⇐ Error

Base class for all server errors

Kind: global class
Extends: Error
Category: Errors


ServerError ⇐ ServerError

Base class for all authentication errors

Kind: global variable
Extends: ServerError
Category: Errors


AuthError ⇐ AuthError

Wrong credentials error

Kind: global variable
Extends: AuthError
Category: Errors


AuthWrongCredentialsError ⇐ AuthError

Authentication required error

Kind: global variable
Extends: AuthError
Category: Errors


AuthRequiredError ⇐ AuthError

Missing credentials error

Kind: global variable
Extends: AuthError
Category: Errors


AuthMissingCredentials ⇐ ServerError

Base class for all client errors

Kind: global variable
Extends: ServerError
Category: Errors


ClientError ⇐ ClientError

Timeout error

Kind: global variable
Extends: ClientError
Category: Errors


TimeoutError ⇐ ClientError

Base class for all connection errors

Kind: global variable
Extends: ClientError
Category: Errors


ConnectionError ⇐ ConnectionError

Server disconnect error

Kind: global variable
Extends: ConnectionError
Category: Errors


Done in 2.81s.