Bump nodejs-rfb, fix vncvm

This commit is contained in:
Elijah R
2025-06-05 15:45:36 -04:00
parent 495a212c5f
commit 5621067c38
4 changed files with 56 additions and 26 deletions

View File

@@ -12,7 +12,7 @@
"author": "Elijah R, modeco80",
"license": "GPL-3.0",
"dependencies": {
"@computernewb/nodejs-rfb": "^0.3.0",
"@computernewb/nodejs-rfb": "^0.4.2",
"@computernewb/superqemu": "^0.3.0",
"@cvmts/cvm-rs": "*",
"@maxmind/geoip2-node": "^5.0.0",

View File

@@ -103,9 +103,9 @@ async function start() {
TheProtocolManager.registerProtocol("guacamole", () => new GuacamoleProtocol);
TheProtocolManager.registerProtocol("binary1", () => new BinRectsProtocol);
await VM.Start();
// Start up the server
var CVM = new CollabVMServer(Config, VM, banmgr, auth, geoipReader);
await VM.Start();
var WS = new WSServer(Config, banmgr);
WS.on('connect', (client: User) => CVM.connectionOpened(client));

View File

@@ -36,24 +36,6 @@ export default class VNCVM extends EventEmitter implements VM {
await this.Start();
}
}
private Connect() {
if (this.vnc) {
this.Disconnect();
}
this.vnc = new VncDisplay({
host: this.def.vncHost,
port: this.def.vncPort
});
let self = this;
this.vnc.on('connected', () => {
self.logger.info('Connected');
self.SetState(VMState.Started);
});
}
private Disconnect() {
if (this.vnc) {
this.vnc.Disconnect();
@@ -69,10 +51,24 @@ export default class VNCVM extends EventEmitter implements VM {
StartDisplay(): void {
this.logger.info('Connecting to VNC server');
this.Connect();
let self = this;
this.vnc = new VncDisplay({
host: this.def.vncHost,
port: this.def.vncPort,
path: null
});
self.vnc!.on('connected', () => {
self.logger.info('Connected to VNC server');
self.SetState(VMState.Started);
});
self.vnc!.Connect();
}
async Start(): Promise<void> {
this.Disconnect();
if (this.def.startCmd) await execaCommand(this.def.startCmd, { shell: true });
this.SetState(VMState.Started);
}