misc server cleanup
This commit is contained in:
parent
115a78be01
commit
7b9c71d534
1 changed files with 16 additions and 7 deletions
|
@ -147,24 +147,22 @@ class SocketVM extends EventEmitter {
|
||||||
private vm: QemuVM;
|
private vm: QemuVM;
|
||||||
private display: QemuDisplay;
|
private display: QemuDisplay;
|
||||||
|
|
||||||
private timer: ExtendableTimer = null;
|
private timer: ExtendableTimer = new ExtendableTimer(15);
|
||||||
private users: Array<VMUser> = [];
|
private users: Array<VMUser> = [];
|
||||||
private queue: TurnQueue = new TurnQueue();
|
private queue: TurnQueue = new TurnQueue();
|
||||||
|
|
||||||
constructor(vm: QemuVM) {
|
constructor(vm: QemuVM) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.vm = vm;
|
this.vm = vm;
|
||||||
this.timer = new ExtendableTimer(15);
|
|
||||||
|
|
||||||
this.timer.on('expired', async () => {
|
this.timer.on('expired', async () => {
|
||||||
// bye bye!
|
// bye bye!
|
||||||
console.log(`[SocketVM] VM expired, resetting..`);
|
console.log(`[SocketVM] VM timer expired, resetting..`);
|
||||||
await this.vm.Stop();
|
await this.vm.Stop();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.timer.on('expiry-near', async () => {
|
this.timer.on('expiry-near', async () => {
|
||||||
console.log(`[SocketVM] about to expire!`);
|
console.log(`[SocketVM] VM timer expires in 1 minute.`);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.queue.on('turnQueue', (arr: Array<userAndTime>) => {
|
this.queue.on('turnQueue', (arr: Array<userAndTime>) => {
|
||||||
|
@ -296,14 +294,12 @@ class SocketVM extends EventEmitter {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Shared.MessageType.Key:
|
case Shared.MessageType.Key:
|
||||||
console.log("GOT key event", (message as Shared.KeyMessage).keysym, (message as Shared.KeyMessage).pressed)
|
|
||||||
if(user != this.queue.CurrentUser())
|
if(user != this.queue.CurrentUser())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(this.display == null)
|
if(this.display == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
console.log("valid key event", (message as Shared.KeyMessage).keysym, (message as Shared.KeyMessage).pressed);
|
|
||||||
this.display.KeyboardEvent((message as Shared.KeyMessage).keysym, (message as Shared.KeyMessage).pressed);
|
this.display.KeyboardEvent((message as Shared.KeyMessage).keysym, (message as Shared.KeyMessage).pressed);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -392,6 +388,19 @@ class SocketVM extends EventEmitter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CONFIG types (not used yet)
|
||||||
|
export type SocketComputerConfig_VM = {
|
||||||
|
ramsize: string,
|
||||||
|
hda: string,
|
||||||
|
netdev: string
|
||||||
|
};
|
||||||
|
|
||||||
|
export type SocketComputerConfig = {
|
||||||
|
listen: string,
|
||||||
|
port: number
|
||||||
|
vm: SocketComputerConfig_VM
|
||||||
|
};
|
||||||
|
|
||||||
export class SocketComputerServer {
|
export class SocketComputerServer {
|
||||||
private vm: SocketVM = null;
|
private vm: SocketVM = null;
|
||||||
private fastify: FastifyInstance = fastify({
|
private fastify: FastifyInstance = fastify({
|
||||||
|
|
Loading…
Reference in a new issue