Skip to content

Commit

Permalink
port change 2
Browse files Browse the repository at this point in the history
  • Loading branch information
jayrajroshan committed Jul 27, 2020
1 parent 4f94ac7 commit 9c19129
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions index.js
@@ -1,7 +1,7 @@
const express = require('express')
const bodyParser = require('body-parser')
const app = express()
const port = 3000
const PORT = process.env.PORT || 3000;
const path = require('path')
var ws = require('ws')

Expand Down Expand Up @@ -55,8 +55,8 @@ const wsServer = new ws.Server({ noServer: true });
// });


const server = app.listen(process.env.PORT || 3000, () => {
console.log(`App running on port ${process.env.PORT || 3000}.`)
const server = app.listen(PORT, () => {
console.log(`App running on port ${PORT}.`)
})
server.on('upgrade', (request, socket, head) => {
wsServer.handleUpgrade(request, socket, head, socket => {
Expand Down
4 changes: 3 additions & 1 deletion public/assets/speed.js
@@ -1,4 +1,6 @@
var ws = new WebSocket('ws://localhost:5000');
var HOST = location.origin.replace(/^http/, 'ws')

var ws = new WebSocket(HOST);

ws.onopen = function () {
console.log('websocket is connected ...')
Expand Down

0 comments on commit 9c19129

Please sign in to comment.