第一步-配置好密钥
// 配置wss的密钥
global.__keyOption = {
key : fs.readFileSync("./https/key.key"),
cert: fs.readFileSync("./https/chain.crt")
}
第二步-创建wss服务器
const wss = require("nodejs-websocket");
// wss.createServer([options], [callback])
wss.createServer({secure: true, ...__keyOption}, async function (conn) {
// ...
// ...
// ...
})