User.ts 611 Bytes
import { Connection } from "../connection/Connection";
import { HandlerMap } from "../message/MessageHandler";
import { Room } from "../room/Room";
import { UserData } from "./types";

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, {});
  }

  public getData(): UserData {
    return {
      username: this.username,
    };
  }
}