mokou-websocket

1.0.6 • Public • Published

Mokou WebSocket

Reconnecting web socket

Example:

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
}

MokouWebsocket

Kind: global class

new MokouWebsocket(url, [protocols])

MokouWebsocket - simple reconnecting websocket for nodejs

Param Type Default Description
url string WebSocket url
[protocols] Array.<Object> [] WebSocket protocols

mokouWebsocket.readyState : number

Websocket state

Kind: instance property of MokouWebsocket

mokouWebsocket.onopen(e)

WebSocket events callbacks

Kind: instance method of MokouWebsocket

Param Description
e WebSocket event

mokouWebsocket.send(data)

Sends given string to the other side

Kind: instance method of MokouWebsocket

Param Type
data string

mokouWebsocket.close()

Close WebSocket connection

Kind: instance method of MokouWebsocket

mokouWebsocket.refresh()

Refresh WebSocket connection

Kind: instance method of MokouWebsocket

MokouWebsocket~connect([reconnectAttempt])

Kind: inner method of MokouWebsocket

Param Type Default Description
[reconnectAttempt] bool false indicates if MokouWebSocket trying to reconnect to server

Readme

Keywords

Package Sidebar

Install

npm i mokou-websocket

Weekly Downloads

8

Version

1.0.6

License

MIT

Unpacked Size

16.6 kB

Total Files

6

Last publish

Collaborators

  • kotborealis