update readme
This commit is contained in:
parent
fc082c45e8
commit
9beec2ff3a
13
README.md
13
README.md
|
@ -2,13 +2,19 @@
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// constructor(socketAddress, options = [], autoReconnect = true, debugName = null)
|
// constructor(socketAddress, options = [], autoReconnect = true, debugName = null)
|
||||||
|
// debugName is used for console logs. If omitted socketAddress will be used instead.
|
||||||
let socket = SmartWebSocket("ws://127.0.0.1:8080", [], true, "sock");
|
let socket = SmartWebSocket("ws://127.0.0.1:8080", [], true, "sock");
|
||||||
|
|
||||||
|
socket.url = "ws://127.0.0.1:8081";
|
||||||
|
socket.protocols = [];
|
||||||
|
socket.debugName = "mySock";
|
||||||
|
|
||||||
// close if connection is open, then re-open connection
|
// close if connection is open, then re-open connection
|
||||||
|
// applies changes to socket.url and socket.protocols
|
||||||
socket.reconnect()
|
socket.reconnect()
|
||||||
|
|
||||||
// close socket and disable auto-reconnect
|
// internal WebSocket element.
|
||||||
socket.close()
|
console.log(socket.socket);
|
||||||
|
|
||||||
// is socket connection open
|
// is socket connection open
|
||||||
if (socket.isReady()) {
|
if (socket.isReady()) {
|
||||||
|
@ -35,4 +41,7 @@ socket.on("anotherEvent", (data) => {
|
||||||
socket.on("open", (event) => {
|
socket.on("open", (event) => {
|
||||||
console.log(event);
|
console.log(event);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// close socket and disable auto-reconnect
|
||||||
|
socket.close()
|
||||||
```
|
```
|
Reference in New Issue