feat: allow redirecting to preset

This commit is contained in:
Carlos Valente
2025-02-21 14:34:57 +01:00
committed by Carlos Valente
parent 88b8e83494
commit b8d7324be0
8 changed files with 152 additions and 64 deletions
+15 -10
View File
@@ -59,11 +59,13 @@ export class SocketServer implements IAdapter {
}
});
const clientId = generateId();
const clientName = getRandomName();
this.clients.set(clientId, {
type: 'unknown',
identify: false,
name: getRandomName(),
name: clientName,
origin: '',
path: '',
});
@@ -72,15 +74,11 @@ export class SocketServer implements IAdapter {
ws.send(
JSON.stringify({
type: 'client-id',
payload: clientId,
}),
);
ws.send(
JSON.stringify({
type: 'client-name',
payload: this.clients.get(clientId).name,
type: 'client',
payload: {
clientId,
clientName,
},
}),
);
@@ -128,6 +126,13 @@ export class SocketServer implements IAdapter {
return;
}
if (type === 'set-client-patch') {
if (payload && typeof payload == 'object') {
this.clients.set(clientId, { ...this.clients.get(clientId), ...payload });
}
return;
}
if (type === 'set-client-type') {
if (payload && typeof payload == 'string') {
const previousData = this.clients.get(clientId);