Re: Websockets API / CloseEvent and readyState

No comments to this?

I wish the API will be changed and the awkward CloseEvent
interface will be removed.

-Olli

On 3/18/10 12:15 AM, Olli Pettay wrote:
> Hi all,
>
> 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.
> For example:
> 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.
>
> 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();
> }
> }
>
> .wasClean feels and sounds bad :/
>
> -Olli
>
>
>
>

Received on Wednesday, 14 April 2010 17:32:44 UTC