[whatwg] WebSocket bufferedAmount includes overhead or not

Jonas Sicking jonas at sicking.cc
Wed Mar 31 14:45:37 PDT 2010


On Tue, Mar 30, 2010 at 11:20 PM, Niklas Beischer <no at opera.com> wrote:
> On Wed, 31 Mar 2010 09:38:21 +0300, Jonas Sicking <jonas at sicking.cc> wrote:
>
>> On Tue, Mar 30, 2010 at 9:56 PM, Boris Zbarsky <bzbarsky at mit.edu> wrote:
>>>
>>> On 3/30/10 10:22 AM, Jonas Sicking wrote:
>>>>
>>>> Making it implementation dependent is likely to lead to website
>>>> incompatibilities. Such as:
>>>>
>>>> ws = new WebSocket(...);
>>>> ws.onopen = function() {
>>>>  ws.send(someString);
>>>>  if (ws.bufferedAmount>  X) {
>>>>    doStuff();
>>>
>>> Can bufferedAmount not change due to data actually hitting the network
>>> during the execution of this code?  As in, will all the someString data
>>> be
>>> buffered immediately after that send() call?
>>
>> I would have expected bufferedAmount to only change as a result of an
>> event being posted to the main event loop.
>
> I'm certainly no EcmaScript expert but now I'm confused. What event would
> that be? There is no 'onsent' event. Would bufferedAmount not change until
> there is an 'onerror' or 'onclosed' event?

No, an event that's internal to the implementation. See how event
queues work as defined by HTML5.

/ Jonas



More information about the whatwg mailing list