[whatwg] WebSocket: Events instead of polling bufferedAmount?
ian at hixie.ch
Thu Mar 25 15:01:02 PDT 2010
On Thu, 25 Mar 2010, Ivan Kozik wrote:
> I would much prefer that WebSocket fired an event as data is sent,
> instead of having applications poll bufferedAmount. [...]
> But, being forced to poll bufferedAmount is suboptimal:
> setTimeout(..., 0) may take 16ms or more to fire, so without hacks,
> applications are limited to making decisions (to generate more data or
> not) at ~16ms intervals.
Realistically, we probably wouldn't fire events much more often than this
either. I mean, we wouldn't want to fire an event with each byte sent,
right? That would quickly overwhelm the system. It's not clear to me what
else we would do, though.
We could have an event that fires when bufferedAmount becomes zero
(everything has been sent) or when bufferedAmount doesn't go down for a
bit (stall), or resumes going down after a stall, but I would feel more
comfortable waiting until WebSocket has been used for a while before
adding such events, so that we could work out what it was people actually
wanted to use, and then provide those.
Ian Hickson U+1047E )\._.,--....,'``. fL
http://ln.hixie.ch/ U+263A /, _.. \ _\ ;`._ ,.
Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'
More information about the whatwg