t00-multiuser/server/objects/RemoteUser.ts

39 lines
1.1 KiB
TypeScript
Raw Normal View History

2024-04-21 15:35:47 +01:00
import { WebSocket } from "ws";
export default class RemoteUser {
private static USER_IDS = 0;
2024-05-08 01:02:18 +01:00
public readonly socket:WebSocket;
public readonly connectionUUID:string;
2024-04-21 15:35:47 +01:00
public readonly id:number;
public readonly username:string;
public readonly currentURL:string;
public readonly rawURL:string = "";
public cursorX:number = 0;
public cursorY:number = 0;
public allowedPings:number;
public lastPingReset:number;
2024-04-26 03:01:06 +01:00
public userId:number;
2024-05-06 15:41:26 +01:00
public groupId:number = Number.MIN_VALUE;
2024-04-26 03:01:06 +01:00
public groupName:string;
2024-05-08 01:02:18 +01:00
public lastKeepAliveTime:number;
2024-04-21 15:35:47 +01:00
2024-05-08 01:02:18 +01:00
constructor(socket:WebSocket, connectionUUID:string, username:string, currentURL:string, rawURL:string, userId:number, groupId:number, groupName:string) {
2024-04-21 15:35:47 +01:00
this.socket = socket;
2024-05-08 01:02:18 +01:00
this.connectionUUID = connectionUUID;
2024-04-21 15:35:47 +01:00
this.id = RemoteUser.USER_IDS++;
this.username = username;
this.currentURL = currentURL;
this.rawURL = rawURL;
this.allowedPings = 10;
this.lastPingReset = Date.now();
2024-04-26 03:01:06 +01:00
this.userId = userId;
this.groupId = groupId;
this.groupName = groupName;
2024-05-08 01:02:18 +01:00
this.lastKeepAliveTime = Date.now();
2024-04-21 15:35:47 +01:00
}
send(data:Buffer) {
this.socket.send(data);
}
}