diff --git a/ledder/server/Render.ts b/ledder/server/Render.ts index dc7d18b..75d5062 100644 --- a/ledder/server/Render.ts +++ b/ledder/server/Render.ts @@ -10,14 +10,18 @@ export class Render { public readonly animationManager: AnimationManager public readonly controlGroup: ControlGroup + public readonly description: string protected display: Display protected readonly box: PixelBox protected readonly scheduler: Scheduler - constructor(display: Display) { + + constructor(display: Display, description='') { this.display = display + this.description=description + this.controlGroup = new ControlGroup('root') this.box = new PixelBox(display) this.scheduler = new Scheduler() @@ -32,7 +36,7 @@ export class Render { this.box.forEachPixel(() => { count++ }) - return (`${count} pixels.\n${this.scheduler.__getStats()}`) + return (`${this.description}: ${count} pixels.\n${this.scheduler.__getStats()}`) } } \ No newline at end of file diff --git a/ledder/server/RenderRealtime.ts b/ledder/server/RenderRealtime.ts index 84c2764..e833728 100644 --- a/ledder/server/RenderRealtime.ts +++ b/ledder/server/RenderRealtime.ts @@ -67,7 +67,7 @@ export class RenderRealtime extends Render { let busy=Math.round( ( 1000-this.idleMS)/10) if (busy<0) busy=0 - console.log(`RenderRealtime: ${this.lateFrames} late. ${this.droppedFrames} dropped. ${ busy }% busy.`) + console.log(`RenderRealtime ${this.description}: ${this.lateFrames} late. ${this.droppedFrames} dropped. ${ busy }% busy.`) this.lastStatUpdate=nowUS this.droppedFrames=0; this.lateFrames=0; diff --git a/ledder/server/RpcServer.ts b/ledder/server/RpcServer.ts index 3f7fd0d..ad2d492 100644 --- a/ledder/server/RpcServer.ts +++ b/ledder/server/RpcServer.ts @@ -60,7 +60,8 @@ export class RpcServer extends Rpc { // @ts-ignore this.app.ws('/ws', (ws, req) => { this.idCount++ - let context = new WsContext(ws, this.server, this.idCount) + let context = new WsContext(ws, this.server, this.idCount, req.socket.remoteAddress) + ws.on('message', async (msg) => { // console.log("RPC request: ", msg) diff --git a/ledder/server/WsContext.ts b/ledder/server/WsContext.ts index 3bae17c..fe65838 100644 --- a/ledder/server/WsContext.ts +++ b/ledder/server/WsContext.ts @@ -12,16 +12,18 @@ export class WsContext { client: JSONRPCServerAndClient renderLoop: RenderRealtime id: number + remoteAddress:string statsInterval: any started: boolean - constructor(ws: WebSocket, client, id) { + constructor(ws: WebSocket, client, id, remoteAddress) { this.ws = ws this.client = client this.id = id this.started = false - console.log(`WsContext: New session ${id}`) + this.remoteAddress=remoteAddress + console.log(`WsContext: New session ${id} ${remoteAddress}`) } @@ -43,7 +45,7 @@ export class WsContext { let display = new DisplayWebsocket(width, height, this.ws) - this.renderLoop = new RenderRealtime(display) + this.renderLoop = new RenderRealtime(display, `${this.id} ${this.remoteAddress}`) //todo: add delay or queue this.renderLoop.controlGroup.__onReset(() => { this.request("control.reset").then(() => { @@ -59,9 +61,9 @@ export class WsContext { this.renderLoop.start() - this.statsInterval = setInterval(() => { - console.log(`Preview stats ${this.id}: ${this.renderLoop.getStats()}`) - }, 3000) + // this.statsInterval = setInterval(() => { + // console.log(`Preview stats ${this.id}: ${this.renderLoop.getStats()}`) + // }, 3000) }