client: id is always a string, not a number

This commit is contained in:
Reto Brunner 2024-03-03 18:56:13 +01:00
parent c869ea9a73
commit b89b0cad53
2 changed files with 5 additions and 5 deletions

View file

@ -93,7 +93,7 @@ class Client {
[socketId: string]: {token: string; openChannel: number};
};
config!: UserConfig;
id!: number;
id: string;
idMsg!: number;
idChan!: number;
name!: string;
@ -108,12 +108,12 @@ class Client {
fileHash!: string;
constructor(manager: ClientManager, name?: string, config = {} as UserConfig) {
this.id = uuidv4();
_.merge(this, {
awayMessage: "",
lastActiveChannel: -1,
attachedClients: {},
config: config,
id: uuidv4(),
idChan: 1,
idMsg: 1,
name: name,
@ -226,7 +226,7 @@ class Client {
emit(event: string, data?: any) {
if (this.manager !== null) {
this.manager.sockets.in(this.id.toString()).emit(event, data);
this.manager.sockets.in(this.id).emit(event, data);
}
}
@ -771,7 +771,7 @@ class Client {
quit(signOut?: boolean) {
const sockets = this.manager.sockets.sockets;
const room = sockets.adapter.rooms.get(this.id.toString());
const room = sockets.adapter.rooms.get(this.id);
if (room) {
for (const user of room) {

View file

@ -818,7 +818,7 @@ function initializeClient(
});
// socket.join is a promise depending on the adapter.
void socket.join(client.id?.toString());
void socket.join(client.id);
const sendInitEvent = (tokenToSend: string | null) => {
socket.emit("init", {