increase logging (#7)

This commit is contained in:
alexandrubratu8x8 2022-11-29 11:03:38 +02:00 committed by GitHub
parent 8ccd9d91f9
commit 4cdf41a899
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 5 deletions

1
.gitignore vendored
View file

@ -1,3 +1,4 @@
.DS_Store .DS_Store
dist dist
node_modules node_modules
deploy.sh

View file

@ -32,6 +32,7 @@
"lint": "eslint .", "lint": "eslint .",
"lint-fix": "eslint . --fix", "lint-fix": "eslint . --fix",
"start": "tsc && node dist/index.js", "start": "tsc && node dist/index.js",
"start:local": "tsc && DEBUG='engine,app,socket.io:client,server' node dist/index.js",
"start:dev": "cross-env NODE_ENV=development ts-node-dev --respawn --transpile-only src/index.ts" "start:dev": "cross-env NODE_ENV=development ts-node-dev --respawn --transpile-only src/index.ts"
}, },
"devDependencies": { "devDependencies": {

View file

@ -47,10 +47,10 @@ prometheus.metrics(io, {
}); });
io.on('connection', socket => { io.on('connection', socket => {
ioDebug('connection established!'); serverDebug(`connection established! ${socket.conn.request.url}`);
io.to(`${socket.id}`).emit('init-room'); io.to(`${socket.id}`).emit('init-room');
socket.on('join-room', roomID => { socket.on('join-room', roomID => {
socketDebug(`${socket.id} has joined ${roomID}`); serverDebug(`${socket.id} has joined ${roomID} for url ${socket.conn.request.url}`);
socket.join(roomID); socket.join(roomID);
if (io.sockets.adapter.rooms[roomID].length <= 1) { if (io.sockets.adapter.rooms[roomID].length <= 1) {
io.to(`${socket.id}`).emit('first-in-room'); io.to(`${socket.id}`).emit('first-in-room');
@ -66,7 +66,7 @@ io.on('connection', socket => {
socket.on( socket.on(
'server-broadcast', 'server-broadcast',
(roomID: string, encryptedData: ArrayBuffer, iv: Uint8Array) => { (roomID: string, encryptedData: ArrayBuffer, iv: Uint8Array) => {
socketDebug(`${socket.id} sends update to ${roomID}`); serverDebug(`${socket.id} sends update to ${roomID}`);
socket.broadcast.to(roomID).emit('client-broadcast', encryptedData, iv); socket.broadcast.to(roomID).emit('client-broadcast', encryptedData, iv);
} }
); );
@ -74,7 +74,7 @@ io.on('connection', socket => {
socket.on( socket.on(
'server-volatile-broadcast', 'server-volatile-broadcast',
(roomID: string, encryptedData: ArrayBuffer, iv: Uint8Array) => { (roomID: string, encryptedData: ArrayBuffer, iv: Uint8Array) => {
socketDebug(`${socket.id} sends volatile update to ${roomID}`); serverDebug(`${socket.id} sends volatile update to ${roomID}`);
socket.volatile.broadcast socket.volatile.broadcast
.to(roomID) .to(roomID)
.emit('client-broadcast', encryptedData, iv); .emit('client-broadcast', encryptedData, iv);