| 21 | |
| 22 | class Control { |
| 23 | constructor(data, color) { |
| 24 | this.colorM = color; |
| 25 | this.colors = this.colorM.get(); |
| 26 | |
| 27 | this.enable = false; |
| 28 | this.sender = data.send; |
| 29 | this.closer = data.close; |
| 30 | this.resizer = data.resize; |
| 31 | this.subs = new subscribe.Subscribe(); |
| 32 | |
| 33 | let self = this; |
| 34 | |
| 35 | data.events.place("stdout", async rd => { |
| 36 | try { |
| 37 | self.subs.resolve(await reader.readCompletely(rd)); |
| 38 | } catch (e) { |
| 39 | // Do nothing |
| 40 | } |
| 41 | }); |
| 42 | |
| 43 | data.events.place("stderr", async rd => { |
| 44 | try { |
| 45 | self.subs.resolve(await reader.readCompletely(rd)); |
| 46 | } catch (e) { |
| 47 | // Do nothing |
| 48 | } |
| 49 | }); |
| 50 | |
| 51 | data.events.place("completed", () => { |
| 52 | self.closed = true; |
| 53 | self.colorM.forget(self.colors.color); |
| 54 | |
| 55 | self.subs.reject("Remote connection has been terminated"); |
| 56 | }); |
| 57 | } |
| 58 | |
| 59 | echo() { |
| 60 | return false; |