Initial commit: Angular frontend and Expressjs backend
This commit is contained in:
14
worklenz-backend/src/socket.io/commands/on-disconnect.ts
Normal file
14
worklenz-backend/src/socket.io/commands/on-disconnect.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import {Server, Socket} from "socket.io";
|
||||
import db from "../../config/db";
|
||||
|
||||
import {log} from "../util";
|
||||
|
||||
export async function on_disconnect(io: Server, socket: Socket, reason?: string) {
|
||||
log(socket.id, `disconnected (${reason})`);
|
||||
try {
|
||||
const q = "UPDATE users SET socket_id = NULL WHERE socket_id = $1";
|
||||
await db.query(q, [socket.id]);
|
||||
} catch (error) {
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user