29 lines
728 B
TypeScript
29 lines
728 B
TypeScript
|
import { WebSocket } from "ws";
|
||
|
|
||
|
export default class RemoteUser {
|
||
|
private static USER_IDS = 0;
|
||
|
|
||
|
private readonly socket:WebSocket;
|
||
|
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;
|
||
|
|
||
|
constructor(socket:WebSocket, username:string, currentURL:string, rawURL:string) {
|
||
|
this.socket = socket;
|
||
|
this.id = RemoteUser.USER_IDS++;
|
||
|
this.username = username;
|
||
|
this.currentURL = currentURL;
|
||
|
this.rawURL = rawURL;
|
||
|
this.allowedPings = 10;
|
||
|
this.lastPingReset = Date.now();
|
||
|
}
|
||
|
|
||
|
send(data:Buffer) {
|
||
|
this.socket.send(data);
|
||
|
}
|
||
|
}
|