2024-04-18 23:18:49 +01:00
|
|
|
import { WebSocket } from "ws";
|
|
|
|
|
|
|
|
export default class User {
|
|
|
|
private static USER_IDS = 0;
|
|
|
|
|
|
|
|
private readonly socket:WebSocket;
|
|
|
|
public readonly id:number;
|
|
|
|
public readonly username:string;
|
|
|
|
public readonly currentURL:string;
|
2024-04-20 17:20:13 +01:00
|
|
|
public readonly rawURL:string = "";
|
2024-04-19 00:18:12 +01:00
|
|
|
public cursorX:number = 0;
|
|
|
|
public cursorY:number = 0;
|
2024-04-20 17:20:13 +01:00
|
|
|
public allowedPings:number;
|
|
|
|
public lastPingReset:number;
|
2024-04-18 23:18:49 +01:00
|
|
|
|
2024-04-20 17:20:13 +01:00
|
|
|
constructor(socket:WebSocket, username:string, currentURL:string, rawURL:string) {
|
2024-04-18 23:18:49 +01:00
|
|
|
this.socket = socket;
|
|
|
|
this.id = User.USER_IDS++;
|
|
|
|
this.username = username;
|
|
|
|
this.currentURL = currentURL;
|
2024-04-20 17:20:13 +01:00
|
|
|
this.rawURL = rawURL;
|
|
|
|
this.allowedPings = 10;
|
|
|
|
this.lastPingReset = Date.now();
|
2024-04-18 23:18:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
send(data:Buffer) {
|
|
|
|
this.socket.send(data);
|
|
|
|
}
|
|
|
|
}
|