mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-08-05 09:21:30 +02:00
* DOOR.SYS support
* LORD now works via DOOR.SYS at least * Abracadabra: nodeMax, tooManyArt support, etc. * Abracadabra: Exit back to menu * Some code cleanup
This commit is contained in:
parent
144aa6b351
commit
608d4dc094
6 changed files with 246 additions and 85 deletions
45
core/door.js
45
core/door.js
|
@ -4,6 +4,7 @@
|
|||
var spawn = require('child_process').spawn;
|
||||
var events = require('events');
|
||||
|
||||
var _ = require('lodash');
|
||||
var pty = require('pty');
|
||||
|
||||
exports.Door = Door;
|
||||
|
@ -14,6 +15,8 @@ function Door(client, exeInfo) {
|
|||
this.client = client;
|
||||
this.exeInfo = exeInfo;
|
||||
|
||||
this.exeInfo.encoding = this.exeInfo.encoding || 'cp437';
|
||||
|
||||
// exeInfo.cmd
|
||||
// exeInfo.args[]
|
||||
// exeInfo.env{}
|
||||
|
@ -30,44 +33,36 @@ Door.prototype.run = function() {
|
|||
|
||||
var self = this;
|
||||
|
||||
var doorProc = spawn(this.exeInfo.cmd, this.exeInfo.args);
|
||||
|
||||
/*
|
||||
doorProc.stderr.pipe(self.client.term.output);
|
||||
doorProc.stdout.pipe(self.client.term.output);
|
||||
doorProc.stdout.on('data', function stdOutData(data) {
|
||||
console.log('got data')
|
||||
self.client.term.write(data);
|
||||
});
|
||||
|
||||
doorProc.stderr.on('data', function stdErrData(data) {
|
||||
console.log('got error data')
|
||||
self.client.term.write(data);
|
||||
});
|
||||
|
||||
doorProc.on('close', function closed(exitCode) {
|
||||
console.log('closed')
|
||||
self.emit('closed', exitCode); // just fwd on
|
||||
});
|
||||
*/
|
||||
var door = pty.spawn(this.exeInfo.cmd, this.exeInfo.args, {
|
||||
var door = pty.spawn(self.exeInfo.cmd, self.exeInfo.args, {
|
||||
cols : self.client.term.termWidth,
|
||||
rows : self.client.term.termHeight,
|
||||
// :TODO: cwd
|
||||
env : self.exeInfo.env,
|
||||
});
|
||||
|
||||
// :TODO: can we pause the stream, write our own "Loading...", then on resume?
|
||||
|
||||
//door.pipe(self.client.term.output);
|
||||
self.client.term.output.pipe(door);
|
||||
|
||||
// :TODO: do this with pluggable pipe/filter classes
|
||||
|
||||
door.setEncoding('cp437');
|
||||
door.setEncoding(this.exeInfo.encoding);
|
||||
|
||||
door.on('data', function doorData(data) {
|
||||
self.client.term.write(data);
|
||||
//console.log(data);
|
||||
});
|
||||
//*/
|
||||
|
||||
door.on('close', function closed() {
|
||||
console.log('closed...')
|
||||
self.client.term.output.unpipe(door);
|
||||
self.client.term.output.resume();
|
||||
});
|
||||
|
||||
door.on('exit', function exited(code) {
|
||||
self.client.log.info( { code : code }, 'Door exited');
|
||||
|
||||
door.removeAllListeners();
|
||||
|
||||
self.emit('finished');
|
||||
});
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue