Same Port
This commit is contained in:
parent
61467f2635
commit
fcfacb1e96
1 changed files with 15 additions and 4 deletions
19
index.js
19
index.js
|
@ -30,9 +30,9 @@ app.get("/v1/lanyard", (req, res) => {
|
|||
res.send(lanyardData)
|
||||
})
|
||||
|
||||
app.listen(PORT, () => {
|
||||
console.log("API is now listening on port 8080!")
|
||||
})
|
||||
// app.listen(PORT, () => {
|
||||
// console.log("API is now listening on port 8080!")
|
||||
// })
|
||||
|
||||
var lanyard = new WebSocket('wss://api.lanyard.rest/socket')
|
||||
|
||||
|
@ -70,7 +70,14 @@ lanyard.addEventListener("message", async (res) => {
|
|||
}
|
||||
})
|
||||
|
||||
wsServer = new WebSocket.WebSocketServer({ port: 8090 })
|
||||
// wsServer = new WebSocket.WebSocketServer({ port: 8090 })
|
||||
wsServer = WebSocket.Server;
|
||||
let server = require('http').createServer()
|
||||
wsServer = new wsServer({
|
||||
server: server,
|
||||
perMessageDeflate: false
|
||||
})
|
||||
server.on('request', app)
|
||||
|
||||
wsServer.on("connection", function connection(socket) {
|
||||
socket.on('message', function message(data) {
|
||||
|
@ -92,4 +99,8 @@ wsServer.on("connection", function connection(socket) {
|
|||
socket.send(`{ "op": 1 }`)
|
||||
|
||||
sockets.push({socket, lastPing: Date.now()})
|
||||
})
|
||||
|
||||
server.listen(PORT, function() {
|
||||
console.log("API & Websocket now on port: " + PORT)
|
||||
})
|
Loading…
Reference in a new issue