camelot-unchained
Version:
Camelot Unchained Client Library
29 lines (25 loc) • 852 B
text/typescript
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
import EventEmitter from '../EventEmitter';
import {clientEventTopics} from '../defaultTopics';
import ConsoleMessage from '../../core/classes/ConsoleMessage';
import client from '../../core/client';
function run(emitter: EventEmitter, topic: string) {
client.OnConsoleText((text: string) => {
emitter.emit(topic, new ConsoleMessage({text: text}));
});
}
export default class ConsoleListener {
listening: boolean = false;
type: string;
topic: string = clientEventTopics.handlesConsole;
start(emitter: EventEmitter): void {
if (!this.listening) {
this.listening = true;
run(emitter, this.topic);
}
}
}