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