Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v7
- if: ${{ github.ref == 'refs/heads/main' }}
uses: cs50/deploy-to-eb@main
with:
Expand Down
16 changes: 10 additions & 6 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const io = require('socket.io')(http);
const path = require('path');
const mysql = require('mysql');

const port = 8080;
const port = process.env.PORT || 8080;
var board = [];
var cnt = 0;
var connections = 0;
Expand All @@ -19,9 +19,10 @@ var pool = mysql.createPool({
});


app.get('*', function(req, res) {
// Express 5 (path-to-regexp v8) requires wildcards to be named; `/{*splat}` matches `/` and every sub-path
app.get('/{*splat}', function(req, res) {
// req.url
res.sendFile(path.join(__dirname + '/public/index.html'))
res.sendFile(path.join(__dirname, 'public', 'index.html'))
});

io.on('connection', function(socket) {
Expand All @@ -45,9 +46,12 @@ io.on('connection', function(socket) {


// we have a specifc board, subscribe the user to the room
socket.join(thisBoard, function() {
// Socket.IO v3+: join() no longer accepts a callback (it is synchronous with the default adapter),
// so run the post-join logic directly instead of passing it as a callback that would never fire.
socket.join(thisBoard);
(function onJoined() {
console.log("in thisBoard", thisBoard)
console.log("socket is in rooms", socket.rooms);
console.log("socket is in rooms", [...socket.rooms]);

// get a connection to the DB and see if the board exists
pool.getConnection(function(err, connection) {
Expand Down Expand Up @@ -96,7 +100,7 @@ io.on('connection', function(socket) {
}
});
});
});
})();


socket.on('disconnect', function() {
Expand Down
Loading