MWSE/console/official/rtc/mwse-close.js

44 lines
1.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

class MWSECloser{
stdin = null;
stdout = null;
stderr = null;
endpoint = null;
static mwse = null;
constructor(pipe){
this.stdin = pipe.stdin;
this.stdout = pipe.stdout;
this.stderr = pipe.stderr;
}
greenText(text){
this.stdout.writeln(`${this.stdout.COLOR_TEXT(0,255,0)}${text}${this.stdout.COLOR_RESET()}`);
}
redText(text){
this.stdout.writeln(`${this.stdout.COLOR_TEXT(255,0,0)}${text}${this.stdout.COLOR_RESET()}`);
}
async main(args)
{
let mwseConnector = CommandNamespace.namespaces.get('mwse-socket');
if(mwseConnector == null){
this.stderr.writeln(`mwse-socket yok`);
return this.exit();
}
if(mwseConnector.mwse == null){
this.stderr.writeln(`ık bir soket bulunamadı`);
return this.exit();
}
if(mwseConnector.mwse.server?.disconnect == null){
this.stderr.writeln(`MWSE bağlayıcısında hata oluştu`);
return this.exit();
}
mwseConnector.mwse.server.disconnect();
this.greenText("MWSE socketi başarılı bir şekilde kapatıldı");
this.redText(`\n\n${mwseConnector.mwse.server.endpoint.host} sunucusuyla MWSE bağlantısı kesildi\n\n`);
return this.exit();
}
};
CommandNamespace.namespaces.set('mwse-close', MWSECloser);