yarn run v1.22.17 $ jsdoc2md --separators --configure ./jsdoc2md.json --heading-depth 3 ./src/index.ts
- Client
A class representing a HappyPanda X client
- ServerError ⇐
Error
Base class for all server errors
- ServerError ⇐
ServerError
Base class for all authentication errors
- AuthError ⇐
AuthError
Wrong credentials error
- AuthWrongCredentialsError ⇐
AuthError
Authentication required error
- AuthRequiredError ⇐
AuthError
Missing credentials error
- AuthMissingCredentials ⇐
ServerError
Base class for all client errors
- ClientError ⇐
ClientError
Timeout error
- TimeoutError ⇐
ClientError
Base class for all connection errors
- ConnectionError ⇐
ConnectionError
Server disconnect error
- log
The logger
- 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 }
A class representing a HappyPanda X client
Kind: global class
- Client
- new Client(params)
- .timeout ⇒
number
- .on(event, listener) ⇒
Client
- .once(event, listener) ⇒
Client
- .off(event, listener) ⇒
Client
- .alive() ⇒
boolean
- .ready() ⇒
boolean
- .set_server(host, port)
- .is_connected() ⇒
boolean
- .close() ⇒
Promise
- async
- .handshake(params) ⇒
Promise
- .request_auth(ignore_err) ⇒
Promise
- .drop_auth(ignore_err) ⇒
Promise
- .connect(params) ⇒
Promise
- .send(msg) ⇒
Promise
- .send_raw(msg) ⇒
Promise
- .handshake(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 |
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 |
Check if server is still alive
Kind: instance method of Client
Check if client is ready to exchange messages with server
Kind: instance method of Client
Set server address
Kind: instance method of Client
Param | Type | Description |
---|---|---|
host | string |
server host |
port | integer |
server port |
Check if the client is still connected to the server
Kind: instance method of Client
Close the connection
Kind: instance method of Client
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 |
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 |
Logout and invalidates the session
Kind: instance method of Client
Category: async
Param | Type | Description |
---|---|---|
ignore_err | boolean |
ignore error |
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 |
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 |
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 |
The logger
Kind: global constant
Group: Logging
Enable or disable logging
Kind: static property of log
Can be set to a custom logger that will be used instead of console
Kind: static property of log
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 |
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.