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 display: QemuDisplay;
|
||||
|
||||
private timer: ExtendableTimer = null;
|
||||
private timer: ExtendableTimer = new ExtendableTimer(15);
|
||||
private users: Array<VMUser> = [];
|
||||
private queue: TurnQueue = new TurnQueue();
|
||||
|
||||
constructor(vm: QemuVM) {
|
||||
super();
|
||||
|
||||
this.vm = vm;
|
||||
this.timer = new ExtendableTimer(15);
|
||||
|
||||
this.timer.on('expired', async () => {
|
||||
// bye bye!
|
||||
console.log(`[SocketVM] VM expired, resetting..`);
|
||||
console.log(`[SocketVM] VM timer expired, resetting..`);
|
||||
await this.vm.Stop();
|
||||
});
|
||||
|
||||
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>) => {
|
||||
|
@ -296,14 +294,12 @@ class SocketVM extends EventEmitter {
|
|||
break;
|
||||
|
||||
case Shared.MessageType.Key:
|
||||
console.log("GOT key event", (message as Shared.KeyMessage).keysym, (message as Shared.KeyMessage).pressed)
|
||||
if(user != this.queue.CurrentUser())
|
||||
return;
|
||||
|
||||
if(this.display == null)
|
||||
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);
|
||||
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 {
|
||||
private vm: SocketVM = null;
|
||||
private fastify: FastifyInstance = fastify({
|
||||
|
|
Loading…
Reference in a new issue