js WebSocket api code example
Example 1: js connect to websocket
var exampleSocket = new WebSocket("wss://www.example.com/socketserver", "protocolOne");
Example 2: javascript websocket
// npm install --save ws
const WebSocket = require('ws');
const ws = new WebSocket('ws://www.host.com/path');
ws.on('open', function open() {
ws.send('something');
});
ws.on('message', function incoming(data) {
console.log(data);
});