Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
psy0rz committed Dec 28, 2024
1 parent 0994205 commit 2fdbd35
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
8 changes: 6 additions & 2 deletions ledder/server/Render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()}`)
}

}
2 changes: 1 addition & 1 deletion ledder/server/RenderRealtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion ledder/server/RpcServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 8 additions & 6 deletions ledder/server/WsContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@ export class WsContext {
client: JSONRPCServerAndClient<WsContext, WsContext>
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}`)


}
Expand All @@ -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(() => {
Expand All @@ -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)


}
Expand Down

0 comments on commit 2fdbd35

Please sign in to comment.