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

Re: Websockets API / CloseEvent and readyState

From: Simon Pieters <simonp@opera.com>
Date: Thu, 15 Apr 2010 09:05:20 +0200
To: Olli@pettay.fi, "Ian Hickson" <ian@hixie.ch>
Cc: public-webapps@w3.org
Message-ID: <op.va6za60fidj3kv@simon-pieterss-macbook.local>
On Thu, 15 Apr 2010 01:17:35 +0200, Ian Hickson <ian@hixie.ch> wrote:

> 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?

I think CloseEvent and wasClean are fine.

-- 
Simon Pieters
Opera Software
Received on Thursday, 15 April 2010 07:06:07 GMT

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