drashland/wocket

server.createRoom()

crookse opened this issue · 1 comments

This depends on #11 Room class.

Expose the following syntax to create a new room:

class SocketServer {
    const rooms: Room[] = {};
    createRoom(name: string, isPrivate: boolean = false): Room {
      return new Room(name, isPrivate);
    }
}

so that the following can be written:

const server = new SocketServer();
const pub = server.createRoom("My Public Room");
const priv = server.createRoom("My Private Room", true);
pub.rename("My Public Room Renamed");
priv.rename("My Private Room Renamed");
pub.close();
priv.close();

we can close this. the restructure (#13) added socketServer.createChannel()