You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+22Lines changed: 22 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -78,6 +78,11 @@ or
78
78
- Accepts `true` or `false`
79
79
- Default value: `false`
80
80
81
+
#### `automaticOpen`
82
+
- Whether or not the websocket should attempt to connect immediately upon instantiation. The socket can be manually opened or closed at any time using ws.open() and ws.close().
83
+
- Accepts `true` or `false`
84
+
- Default value: `true`
85
+
81
86
#### `reconnectInterval`
82
87
- The number of milliseconds to delay before attempting to reconnect.
83
88
- Accepts `integer`
@@ -95,6 +100,23 @@ or
95
100
96
101
---
97
102
103
+
## Methods
104
+
105
+
#### `ws.open()`
106
+
- Open the Reconnecting Websocket
107
+
108
+
#### `ws.close(code, reason)`
109
+
- Closes the WebSocket connection or connection attempt, if any. If the connection is already CLOSED, this method does nothing.
110
+
-`code` is optional the closing code (default value 1000). [https://tools.ietf.org/html/rfc6455#section-7.4.1](https://tools.ietf.org/html/rfc6455#section-7.4.1)
111
+
-`reason` is the optional reason that the socket is being closed. [https://tools.ietf.org/html/rfc6455#section-7.1.6](https://tools.ietf.org/html/rfc6455#section-7.1.6)
112
+
113
+
#### `ws.refresh()`
114
+
- Refresh the connection if still open (close and then re-open it).
115
+
116
+
#### `ws.send(data)`
117
+
- Transmits data to the server over the WebSocket connection.
118
+
- Accepts @param data a text string, ArrayBuffer or Blob
119
+
98
120
Like this? Check out [websocketd](https://github.com/joewalnes/websocketd) for the simplest way to create WebSocket backends from any programming language.
Copy file name to clipboardExpand all lines: reconnecting-websocket.js
+3Lines changed: 3 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -76,6 +76,9 @@
76
76
* debug
77
77
* - Whether this instance should log debug messages. Accepts true or false. Default: false.
78
78
*
79
+
* automaticOpen
80
+
* - Whether or not the websocket should attempt to connect immediately upon instantiation. The socket can be manually opened or closed at any time using ws.open() and ws.close().
81
+
*
79
82
* reconnectInterval
80
83
* - The number of milliseconds to delay before attempting to reconnect. Accepts integer. Default: 1000.
0 commit comments