feat(chat): send online user in a single socketio message
This commit is contained in:
parent
41fdbfbaaa
commit
bcba86ed8a
9 changed files with 42 additions and 78 deletions
|
|
@ -13,6 +13,7 @@ export function connectedUser(io?: Server, target?: string): number {
|
|||
let count = 0;
|
||||
const seen = new Set<string>();
|
||||
// <- only log/count unique usernames
|
||||
const listBud: string[] = [];
|
||||
for (const [socketId, username] of clientChat) {
|
||||
// Basic checks
|
||||
if (typeof socketId !== 'string' || socketId.length === 0) {
|
||||
|
|
@ -38,11 +39,15 @@ export function connectedUser(io?: Server, target?: string): number {
|
|||
// socket exists and is connected
|
||||
seen.add(username.user);
|
||||
count++;
|
||||
const targetSocketId = target;
|
||||
io.to(targetSocketId!).emit('listBud', username.user);
|
||||
// const targetSocketId = target;
|
||||
// io.to(targetSocketId!).emit('listBud', username.user);
|
||||
listBud.push(username.user);
|
||||
continue;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
if (io && typeof io.sockets?.sockets?.get === 'function' && target) {
|
||||
io.to(target).emit('listBud', listBud);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
set -x
|
||||
# do anything here
|
||||
|
||||
# run the CMD [ ... ] from the dockerfile
|
||||
exec "$@"
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
{
|
||||
"openapi": "3.1.0",
|
||||
"info": {
|
||||
"version": "9.6.1",
|
||||
"title": "@fastify/swagger"
|
||||
},
|
||||
"components": {
|
||||
"schemas": {}
|
||||
},
|
||||
"paths": {},
|
||||
"servers": [
|
||||
{
|
||||
"url": "https://local.maix.me:8888",
|
||||
"description": "direct from docker"
|
||||
},
|
||||
{
|
||||
"url": "https://local.maix.me:8000",
|
||||
"description": "using fnginx"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
// {
|
||||
// "extends": "../tsconfig.base.json",
|
||||
// "compilerOptions": {
|
||||
// "skipLibCheck": true, // skips type checking for all .d.ts files
|
||||
// "moduleResolution": "node",
|
||||
// "esModuleInterop": true,
|
||||
// "types": ["node"] },
|
||||
// "include": ["src/**/*.ts"]
|
||||
// }
|
||||
|
||||
{
|
||||
"extends": "../tsconfig.base.json",
|
||||
"compilerOptions": {},
|
||||
"include": ["src/**/*.ts"]
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue