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

View file

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