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)
|
res.send(lanyardData)
|
||||||
})
|
})
|
||||||
|
|
||||||
app.listen(PORT, () => {
|
// app.listen(PORT, () => {
|
||||||
console.log("API is now listening on port 8080!")
|
// console.log("API is now listening on port 8080!")
|
||||||
})
|
// })
|
||||||
|
|
||||||
var lanyard = new WebSocket('wss://api.lanyard.rest/socket')
|
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) {
|
wsServer.on("connection", function connection(socket) {
|
||||||
socket.on('message', function message(data) {
|
socket.on('message', function message(data) {
|
||||||
|
@ -93,3 +100,7 @@ wsServer.on("connection", function connection(socket) {
|
||||||
|
|
||||||
sockets.push({socket, lastPing: Date.now()})
|
sockets.push({socket, lastPing: Date.now()})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
server.listen(PORT, function() {
|
||||||
|
console.log("API & Websocket now on port: " + PORT)
|
||||||
|
})
|
Loading…
Reference in a new issue