Connection.ts 431 Bytes
import { Socket } from "socket.io";
import { MessageHandlerRegistry } from "../message/MessageHandlerRegistry";
import { User } from "../user/User";

export class Connection {
  public readonly socket: Socket;

  public user?: User;

  constructor(socket: Socket) {
    this.socket = socket;

    MessageHandlerRegistry.registerHandlers(this);
  }

  public get authenticated(): boolean {
    return this.user !== undefined;
  }
}