Constructor
new WS(optionsopt)
- Source:
Parameters:
| Name |
Type |
Attributes |
Description |
options |
object
|
<optional>
|
config params
Properties
| Name |
Type |
Attributes |
Default |
Description |
path |
string
|
<optional>
|
/
|
connect url path name |
query |
object
|
<optional>
|
|
query parameters to send on connect in the url |
retry_timeout |
number
|
<optional>
|
250
|
ms between retries to connect |
retry_factor |
number
|
<optional>
|
|
multiplier for retry timeout |
max_timeout |
number
|
<optional>
|
30000
|
ms for max timeout on retries, once reached restart with retry_timeout |
max_retries |
number
|
<optional>
|
|
how many retries to perform until connected |
max_pending |
number
|
<optional>
|
10
|
how many request to keep in pending queue until connected |
ping_interval |
number
|
<optional>
|
300000
|
ms between pings |
|
Example
app.$ready(async () => {
app.ws = new app.WS({ path: "/ws" });
app.ws.connect();
app.ws.on("ws:message", (data) => { ...});
});
....
app.ws.send("/route/action")
app.ws.send({ path: "/some/path", data: { ...} })