Socket
Book a DemoInstallSign in
Socket

mokou-websocket

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mokou-websocket

Reconnecting websocket

1.0.6
latest
Source
npmnpm
Version published
Weekly downloads
5
Maintainers
1
Weekly downloads
 
Created
Source

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

ParamTypeDefaultDescription
urlstringWebSocket 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

ParamDescription
eWebSocket event

mokouWebsocket.send(data)

Sends given string to the other side

Kind: instance method of MokouWebsocket

ParamType
datastring

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

ParamTypeDefaultDescription
[reconnectAttempt]boolfalseindicates if MokouWebSocket trying to reconnect to server

Keywords

websockets

FAQs

Package last updated on 04 Aug 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.