- From: Ian Hickson <ian@hixie.ch>
- Date: Tue, 27 Oct 2009 05:17:59 +0000 (UTC)
On Sun, 25 Oct 2009, Avi Flax wrote: > > Just one thing struck me as odd: calling send(data) on a?WebSocket > whose readyState is CONNECTING raises an INVALID_STATE_ERR exception, > but calling send(data) on a WebSocket whose readyState is CLOSED does > not raise an exception; it merely returns false. > > This is confusing to me; I would think that a WebSocket which is in the > process of connecting is in an invalid state for sending data, then one > which has closed its connection is also in an invalid state for sending > data. > > I'd really appreciate it if someone could explain the rationale for this > to me. The connection might get closed at any point, e.g. between the script checking if the connection might be closed and the script calling the send() method. Because of this, if we raised an exception when the connection was closed, we'd run the risk of the script randomly throwing an exception in a way that the author likely did not check for. This isn't a problem for the CONNECTING case, since there is an event that fires before the script can use the send() method, and thus the author is unlikely to accidentally run into that exception in a way that wouldn't be quickly caught in testing. -- Ian Hickson U+1047E )\._.,--....,'``. fL http://ln.hixie.ch/ U+263A /, _.. \ _\ ;`._ ,. Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'
Received on Monday, 26 October 2009 22:17:59 UTC