User.ts
754 Bytes
import { UserData } from "../../common/dataType";
import { Connection } from "../connection/Connection";
import { roomListRequestHandler } from "../message/handler/roomListRequestHandler";
import { HandlerMap } from "../message/MessageHandler";
import { Room } from "../room/Room";
export class User {
public readonly username: string;
public readonly connection: Connection;
public room?: Room;
public handler: HandlerMap<User>;
constructor(username: string, connection: Connection) {
this.username = username;
this.connection = connection;
this.handler = new HandlerMap<User>(this, {
roomList: roomListRequestHandler,
});
}
public getData(): UserData {
return {
username: this.username,
};
}
}