4 ms·
I made one of these last week to play with nodejs and WebSockets. My heavily-unoptimized wire protocol used uncompressed JSON objects sent at each mousemove ev
by jjs 16y ago
I made one of these last week to play with nodejs and WebSockets.
My heavily-unoptimized wire protocol used uncompressed JSON objects sent at each mousemove event on the canvas while drawing, which means it's great fun on the LAN, but would choke any affordable Internet link.
It appears that this one solves the problem by limiting the rate at which you can draw—drag the mouse too fast, and it lifts the pencil.
- mrdoob2 16y agoThat's not correct. The drag too fast tweak is there to discourage people scribbling all over the place. The actual "fix" for your problem was to collect commands (mouseMoves) and send them every 75ms instead of sending a command every mouse move. There is also some simple delta stuff to save on BW
- jjs 16y agoIn my case, it's the throughput that was a problem; there was practically zero latency or cost of sending a message using node and WebSockets. I was considering doing some sort of curve-fitting to (lossily) compress the drawing commands. Sending a couple points to describe a quadratic or Bézier curve is a lot nicer than hundreds of points to describe tiny line segments. And, as luck would have it, <canvas> draws both natively! :)