Hi,
I wonder why send() needs to buffer anything after the connection is
closed. bufferedAmount is defined: "If the connection is closed, this
attribute's value will only increase with each call to the send() method
(the number does not reset to zero once the connection closes)"
Why not clear the buffer right after dispatching close event and then
throw if send() is called, or something similar?
Or is the current behavior there just so that the example works;
send new data whenever socket.bufferedAmount == 0. (Though the send may
not actually send the data ever)
The example could be a bit different
var socket = new WebSocket('ws://game.example.com:12010/updates');
socket.onopen = function () {
setInterval(function() {
if (socket.readyState == WebSocket.OPEN && socket.bufferedAmount == 0)
socket.send(getUpdateData());
}, 50);
};
-Olli