Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

close() call should call __flash.close() when CONNECTING #37

Closed
kanaka opened this issue Sep 11, 2010 · 1 comment
Closed

close() call should call __flash.close() when CONNECTING #37

kanaka opened this issue Sep 11, 2010 · 1 comment

Comments

@kanaka
Copy link
Contributor

kanaka commented Sep 11, 2010

Right now the close() call only calls __flash.close() if readyState is OPEN. But it should really call close any time that readyState is not CLOSED or CLOSING.

The case I ran into is when I want to do the following:

  1. make a test connection
  2. tell the server to setup for a connection
  3. connect again

I call close on the test connection, but since it is ignored when CONNECTING, it eventually times out with a error. But by that time I have already issued a new connection, it causes the new connection to fail. close() should cancel CONNECTING state too.

Here is my recommended change:

--- a/web-socket-js/web_socket.js
+++ b/web-socket-js/web_socket.js
@@ -119,7 +119,10 @@
   WebSocket.prototype.close = function() {
     if (!this.__flash) return;
     this.readyState = this.__flash.getReadyState();
-    if (this.readyState != WebSocket.OPEN) return;
+    if ((this.readyState === WebSocket.CLOSED) ||
+        (this.readState === WebSocket.CLOSING)) {
+        return;
+    }
     this.__flash.close();
     // Sets/calls them manually here because Flash WebSocketConnection.close cannot fire events
     // which causes weird error:
@gimite
Copy link
Owner

gimite commented Sep 13, 2010

Thanks for the patch. Patched.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants