mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-13 00:02:37 +10:00
client initiate
This commit is contained in:
29
server/internal/clients/handler.ts
Normal file
29
server/internal/clients/handler.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
|
||||
export interface ClientMetadata {
|
||||
name: string;
|
||||
platform: string;
|
||||
}
|
||||
|
||||
export class ClientHandler {
|
||||
private temporaryClientTable: {
|
||||
[key: string]: { timeout: NodeJS.Timeout; data: ClientMetadata };
|
||||
} = {};
|
||||
|
||||
async initiate(metadata: ClientMetadata) {
|
||||
const clientId = uuidv4();
|
||||
|
||||
this.temporaryClientTable[clientId] = {
|
||||
data: metadata,
|
||||
timeout: setTimeout(() => {
|
||||
if (this.temporaryClientTable[clientId])
|
||||
delete this.temporaryClientTable[clientId];
|
||||
}, 1000 * 60 * 10), // 10 minutes
|
||||
};
|
||||
|
||||
return clientId;
|
||||
}
|
||||
}
|
||||
|
||||
export const clientHandler = new ClientHandler();
|
||||
export default clientHandler;
|
||||
Reference in New Issue
Block a user