4 ms·
I made a little nojs shared drawing board a few years back that worked with MJPEG as the background of an image button ‘<input type="image" ...>’. Clicking the
by donatj 6y ago
I made a little nojs shared drawing board a few years back that worked with MJPEG as the background of an image button ‘<input type="image" ...>’.
Clicking the image button submits the form with x and y click coordinates, and the server returns an HTTP 204 telling it to stay where it is, followed by pushing out the updated jpeg to all connected clients.
It’s pretty fun, and I wanted to have it online all the time but it has a problem I haven’t sorted out where sometimes when a client disconnects the server won’t realize and trying to push them a jpeg locks the whole rendering system.
https://github.com/donatj/imgboard https://github.com/donatj/imgboard
- lawik 6y ago204 you say. Please don't make this rabbit hole deeper for me :)
- donatj 6y ago204 is a wonderful rabbit hole! You can use it to send messages to the server without refreshing the page without JS. It was a pretty common trick in the early 2000s
- dsego 6y agoHow do you detect a success/failure without JS?
- donatj 6y agoSend an actual error page rather than a 204. It's not perfect, but in cases where the server returning an error is very rare, it's fine. Since there is no state anyway, the user hitting back is fine. Most JS apps in my experiences fail to handle server errors with any sort of user feedback at all.
- forgotmypw17 6y agoThank you very much for sharing this. I'm attempting to support every client in every configuration on my web-based forum, and this would be a nice little toy.
- IgorPartola 6y agoThat problem should definitely be solvable. I used MJEPG to create my own streaming server that wasn’t mjpegstreamer and even with HTTPS and reverse proxying there are ways to detect when to stop sending the data, though it isn’t fun to find all the edge cases. I need to revisit and update that project sometime but it was a very neat event loop C implementation that reads frames from a cheap consumer webcam and without doing any reencoding feeds it to connected sockets as an MJPEG stream (it does have support for re-encoding if the camera can’t produce JPEGs). Was a really fun exercise in minimalism and efficiency as my goal was to stream multiple cameras from a single Raspberry Pi back when they were super slow.
- donatj 6y agoI have no doubt, I just haven't found the time. The codes kind of a nasty mess / proof of concept.
- Sephr 6y agoI envisioned this same concept a decade ago[1] but never implemented it. It's nice to see this actually work in practice! [1]: https://stackoverflow.com/questions/2576715/pushing-data-once-a-url-is-requested https://stackoverflow.com/questions/2576715/pushing-data-onc...
- deleted 6y ago[deleted]