Binato/server/ChatManager.ts

19 lines
723 B
TypeScript
Raw Normal View History

2022-11-19 01:06:03 +00:00
import { Channel } from "./objects/Channel";
import { ConsoleHelper } from "../ConsoleHelper";
import { FunkyArray } from "./objects/FunkyArray";
import { DataStreamArray } from "./objects/DataStreamArray";
export class ChatManager {
public chatChannels:FunkyArray<Channel> = new FunkyArray<Channel>();
public streams:DataStreamArray;
public constructor(streams:DataStreamArray) {
this.streams = streams;
}
public AddChatChannel(name:string, description:string, forceJoin:boolean = false) {
const stream = this.streams.CreateStream(`chat_channel:${name}`, false);
this.chatChannels.add(name, new Channel(name, description, stream, forceJoin));
ConsoleHelper.printChat(`Created chat channel [${name}]`);
}
}