W3C home > Mailing lists > Public > whatwg@whatwg.org > February 2011

[whatwg] Websockets Client API

From: Harald Alvestrand <harald@alvestrand.no>
Date: Tue, 22 Feb 2011 19:57:01 +0100
Message-ID: <4D6406FD.3010500@alvestrand.no>
I went through exactly the same exercise some days ago.

It turns out that the "perfectly clear" specification is the 
specification of the Javascript runtime environment, not in the 
particular API specification.

<obTangent>Even in that case, I would prefer to see a separate "open" 
call. It's just cleaner to have the act of object creation separated 
from the act of external communication.</obTangent>.

On 02/21/11 03:51, Robert O'Callahan wrote:
> On Mon, Feb 21, 2011 at 2:34 PM, Bruce Atherton<bruce at callenish.com>  wrote:
>
>> Perhaps you are reading a different spec than I am. The only language I see
>> about queuing tasks involves changing the ready state on the Websocket
>> object. There is nothing in there about waiting until a block of other
>> Javascript code has run before making any other event callbacks.
>>
> http://dev.w3.org/html5/websockets/#feedback-from-the-protocol
> For every event in that section, the user-agent must queue a task to fire
> the event. None of the other sections describe any events.
>
> Let me see if I follow the "perfectly clear" line of reasoning you are
>> using. Your assumption is that a Websocket connection will only be loaded in
>> an event handler like window.onload.
>
> In HTML5-compliant user-agents, all Javascript runs in some task of the
> HTML5 event loop. That task must run to completion before other tasks queued
> by the user-agent will run.
>
> No other events will be delivered until the current event handler finishes.
>> And the event handler that creates the Websocket object will necessarily
>> also be where the event handlers are set on the Websocket object. By making
>> all of these assumptions, it becomes obvious that within a browser this API
>> is safe for callbacks. Do I have that right?
>>
> Yes. You observe correctly that the Web author has to be careful to ensure
> that the event handlers are set on the Websocket object during the same task
> that created it. However, this is a fairly natural requirement that is
> common in the Web platform.
>
> I am reminded of a joke about mathematicians. One argues that it is obvious
>> that claim A follows from B. The other disagrees. After arguing for an hour,
>> the latter finally agrees that A obviously follows from B.
>>
> Yeah :-). By "perfectly clear" I meant that the spec was "unambiguous",
> rather than "obvious to the casual reader" :-).
>
> Rob
Received on Tuesday, 22 February 2011 10:57:01 UTC

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