44 lines
1.4 KiB
JavaScript
44 lines
1.4 KiB
JavaScript
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(`Açı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); |