MWSE/frontend/index.ts

38 lines
1.0 KiB
TypeScript

import {Connection,IConnection} from "./Connection";
import EventPool from "./EventPool";
import Peer from "./Peer";
import Room, { IRoomOptions } from "./Room";
import WSTSProtocol from "./WSTSProtocol";
export default class MWSE {
public server! : Connection;
public WSTSProtocol! : WSTSProtocol;
public EventPooling! : EventPool;
public rooms : Map<string, Room> = new Map();
public pairs : Map<string, Peer> = new Map();
constructor(options: IConnection){
this.server = new Connection(options);
this.server.connect();
this.WSTSProtocol = new WSTSProtocol(this);
this.EventPooling = new EventPool(this);
}
public room(options: IRoomOptions)
{
let room = new Room(this);
room.setRoomOptions(options);
return room;
}
public peer(options: IRoomOptions)
{
let peer = new Peer(this);
peer.setPeerOptions(options);
return peer;
}
};
declare global {
interface Window {
MWSE: any;
}
}
window.MWSE = MWSE;