W3C home > Mailing lists > Public > whatwg@whatwg.org > March 2010

[whatwg] WebSocket: Events instead of polling bufferedAmount?

From: Ian Hickson <ian@hixie.ch>
Date: Thu, 25 Mar 2010 22:01:02 +0000 (UTC)
Message-ID: <Pine.LNX.4.64.1003252157500.4055@ps20323.dreamhostps.com>
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.   `._.-(,_..'--(,_..'`-.;.'
Received on Thursday, 25 March 2010 15:01:02 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:22 UTC