D
D
devekipers2021-07-09 19:40:35
JavaScript
devekipers, 2021-07-09 19:40:35

How to rewrite from ws to wsS?

There is a server connection goes via ws , they ask to do it via wss , how can I implement it help a newbie

const ws = require('ws')

const PORT = {
  CONTROLLER: 3301,
  DISPLAY:    3302
}

const controllerWsServer = new ws.Server({port: PORT['CONTROLLER']})
const displayWsServer = new ws.Server({port: PORT['DISPLAY']})

let controllerWsConnection, displayWsConnection

controllerWsServer.on('connection', connection => {
  controllerWsConnection = connection
  controllerWsConnection.on('message', message => {
    if (displayWsConnection)
      displayWsConnection.send(message)
  })
})

displayWsServer.on('connection', connection => {
  displayWsConnection = connection
})

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question