Add http backend#202
Conversation
|
This is nearly done. Need some cleanup, and resolving some small todos. The server can take multiple clients, who each see the same rendered image. The stream is currently throttled by the slowest connection. Only one client is active: it determines the size of the canvas, and the controls the mouse etc. |
|
A review would be great. Otherwise I'll just merge this in a few days. |
| viewElement.addEventListener('pointerdown', (ev) => { | ||
| // When pointer is down, set focus to the focus-element. | ||
| if (!LOOKS_LIKE_MOBILE) { | ||
| this._focusElement.focus({ preventScroll: true, focusVisble: false }) |
There was a problem hiding this comment.
| this._focusElement.focus({ preventScroll: true, focusVisible: false }) |
another potential upstream bug?
| It is assumed that there is exactly one canvas per connected client. | ||
| Multiple clients can simultaneously connect to the server. They will be served | ||
| the same stream of images. There is one "active" client, which determines | ||
| the pase of rendering. Events from the passive clients are ignored. |
There was a problem hiding this comment.
| the pase of rendering. Events from the passive clients are ignored. | |
| the pace of rendering. Events from the passive clients are ignored. |
|
|
||
|
|
||
| # the loop.run() of this backend uses uvicorn to start a webserver | ||
| loop.run() |
There was a problem hiding this comment.
maybe document that loop.run(host="address", port:1234) takes two kwargs. Potentially the base loop .run should consume kwargs for portability?
Vipitis
left a comment
There was a problem hiding this comment.
I have no webdev experience, so I can't give any input on the core changes.
Managed to try it even with multiple clients. I am not sure what the timeout is, but if the active client tabs away it basically freezes the rendering - but it remains the active client.
Should there be some notice about the bidirectional nature by default? Because you might receive events from untrusted clients that could somehow be malicious (I am not sure how this would be exploited beyond a denial of service, by like requesting really large resolutions for example? or maybe a close event? - people will find a way).
finally an idea: what might be possible when running multiple backends at the same time? For example one "presenter" doing it locally while others observe via http (or like a frame server that encodes a video file to save/stream it)

A backend that runs a webserver that you can connect to with your browser. Multiple clients are supported (eventually).
Using ASGI, so it can run on any ASGI server and we don't have any hard dependencies 🚀
WIP AFM host code, saving here for reference, but I think I'll skip the afm: