add basic socketio to server
This commit is contained in:
parent
45ec6b856a
commit
b29cdae088
8 changed files with 252 additions and 1 deletions
35
src/storage/socketMap.ts
Normal file
35
src/storage/socketMap.ts
Normal file
|
@ -0,0 +1,35 @@
|
|||
import { PermissionObject } from "../type/permissionTypes";
|
||||
|
||||
export interface socketStoreModel {
|
||||
socketId: string;
|
||||
userId: string;
|
||||
username: string;
|
||||
firstname: string;
|
||||
lastname: string;
|
||||
isOwner: string;
|
||||
permissions: PermissionObject;
|
||||
isWebApiRequest: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description store credentials to socket to prevent auth data change while connected
|
||||
*/
|
||||
export abstract class SocketMap {
|
||||
private static store = new Map<string, socketStoreModel>();
|
||||
|
||||
public static write(identifier: string, data: socketStoreModel, overwrite: boolean = false): void {
|
||||
if (!this.exists(identifier) || overwrite) this.store.set(identifier, data);
|
||||
}
|
||||
|
||||
public static read(identifier: string): socketStoreModel {
|
||||
return this.store.get(identifier);
|
||||
}
|
||||
|
||||
public static exists(identifier: string): boolean {
|
||||
return this.store.has(identifier);
|
||||
}
|
||||
|
||||
public static delete(identifier: string): void {
|
||||
this.store.delete(identifier);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue