W3C home > Mailing lists > Public > public-webapps@w3.org > April to June 2010

Re: Websockets API / CloseEvent and readyState

From: Ian Hickson <ian@hixie.ch>
Date: Wed, 14 Apr 2010 23:17:35 +0000 (UTC)
To: Olli@pettay.fi
Cc: public-webapps@w3.org
Message-ID: <Pine.LNX.4.64.1004142314180.875@ps20323.dreamhostps.com>
On Thu, 18 Mar 2010, Olli Pettay wrote:
> 
> I was wondering why to have .wasClean in close event. Is there really 
> need for adding yet another event interface. Especially in this case 
> when there are other quite simple options.

An event interface doesn't seem like much of a burden. Event interfaces 
are so similar to each other that it's pretty simple to just autogenerate 
their code by this point.


> WebSocket could have state ERROR and then in the close event listener 
> the script could check whether connection was closed normally, or 
> whether the state is ERROR and based on that try to reconnect.

That doesn't seem very consistent with other readyState attributes. It 
would also make checking whether the connection is open or not a bit less 
trivial.


> In the script the change would be from
>
> function closelistener(e) {
>   if (e.wasClean) {
>     dosomething();
>   } else {
>     reconnect();
>   }
> }
> 
> to
>
> function closelistener(e) {
>   if (this.readyState == this.CLOSED) {
>     dosomething();
>   } else {
>     reconnect();
>   }
> }

The first one of these seems simpler.


> .wasClean feels and sounds bad :/

I don't really see why. If it's just the name then I'm happy to change it 
to something else.

Does anyone else have an opinion on this?

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
Received on Wednesday, 14 April 2010 23:18:04 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:38 GMT