message: Implement Rooms in the TestWebSocket and TestWebSocketServer
diff: @@ -9,8 +9,9 @@ import * as moniker from "moniker";
  export class TestWebSocket implements core.IWebSocket {
  private readonly events = new EventEmitter();
  + private readonly rooms = new Set<string>();
  - constructor(public id: string) {
  + constructor(public id: string, private readonly server: TestWebSocketServer) {
  }
  public on(event: string, listener: (...args: any[]) => void) {
  @@ -18,7 +19,12 @@ export class TestWebSocket implements core.IWebSocket {
  }
  public async join(id: string): Promise<void> {
  - return Promise.resolve();
  + if(!this.server.rooms.has(id)){
  + this.server.rooms.set(id, new Set<TestWebSocket>());
  + }
  + this.server.rooms.get(id).add(this);
  + this.rooms.add(id);
  + return;
  }
  public send(event: string, ...args: any[]) {
  @@ -30,9 +36,24 @@ export class TestWebSocket implements core.IWebSocket {
  }
  public broadcastToRoom(roomId: string, event: string, ...args: any[]) {
  + const sockets = this.server.rooms.get(roomId);
  + if(sockets){
  + for(const socket of sockets){
  + if(socket !== this){
  + socket.events.emit(event, ...args);
  + }
  + }
  + }
  }
  public emitToRoom(roomId: string, event: string, ...args: any[]) {
  + const sockets = this.server.rooms.get(roomId);
  + if(sockets){
  + for(const socket of sockets){
  + socket.events.emit(event, ...args);
  +
  + }
  + }
  }
  public removeListener(event: string, listener: (...args: any[]) => void) {
  @@ -40,11 +61,16 @@ export class TestWebSocket implements core.IWebSocket {
  }
  public disconnect(close?: boolean) {
  - return;
  + for(const room of this.rooms){
  + this.server.rooms.get(room).delete(this);
  }
  }
  +}
  +
  export class TestWebSocketServer implements core.IWebSocketServer {
  + public rooms = new Map<string, Set<TestWebSocket>>();
  +
  private readonly events = new EventEmitter();
  public on(event: string, listener: (...args: any[]) => void) {
  @@ -57,7 +83,7 @@ export class TestWebSocketServer implements core.IWebSocketServer {
  }
  public createConnection(): TestWebSocket {
  - const socket = new TestWebSocket(moniker.choose());
  + const socket = new TestWebSocket(moniker.choose(), this);
  const mockRequest = {url: "TestWebSocket"};
  this.events.emit("connection", socket, mockRequest);
  return socket;
  