Reconnecting web socket
var MokouWebsocket = require("mokou-websocket");
var ws = new MokouWebsocket("ws://127.0.0.1:8001");
ws.onopen=function(e){
//onopen
}
ws.onclose=function(e){
//onclose
}
ws.onconnecting=function(e){
//onconnecting
}
ws.onerror=function(e){
//onerror
}
ws.onmessage=function(e){
//onmessage
}
Kind: global class
-
MokouWebsocket
- new MokouWebsocket(url, [protocols])
-
instance
-
.readyState :
number
- .onopen(e)
- .send(data)
- .close()
- .refresh()
-
.readyState :
- inner
MokouWebsocket - simple reconnecting websocket for nodejs
Param | Type | Default | Description |
---|---|---|---|
url | string |
WebSocket url | |
[protocols] | Array.<Object> |
[] |
WebSocket protocols |
Websocket state
Kind: instance property of MokouWebsocket
WebSocket events callbacks
Kind: instance method of MokouWebsocket
Param | Description |
---|---|
e | WebSocket event |
Sends given string to the other side
Kind: instance method of MokouWebsocket
Param | Type |
---|---|
data | string |
Close WebSocket connection
Kind: instance method of MokouWebsocket
Refresh WebSocket connection
Kind: instance method of MokouWebsocket
Kind: inner method of MokouWebsocket
Param | Type | Default | Description |
---|---|---|---|
[reconnectAttempt] | bool |
false |
indicates if MokouWebSocket trying to reconnect to server |