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

Passing the actual location to WebSocketImpl #737

Closed
gulrotkake opened this issue Nov 19, 2012 · 2 comments
Closed

Passing the actual location to WebSocketImpl #737

gulrotkake opened this issue Nov 19, 2012 · 2 comments
Labels

Comments

@gulrotkake
Copy link

Certain WebSocket implementations (for example in Flash, like https://github.com/gimite/web-socket-js) require that you specify the URL on construction of the object. However, since atmosphere adds a few things to the URL (such as a tracking id and so on) the url we can specify for WebSocketImpl, in our request object, is different from the url that is actually used, this can cause problems.

To work around this problem I changed:

 function _getWebSocket(location) {
                if (_request.webSocketImpl != null) {
                    return _request.webSocketImpl;
                } else {
                    if (window.WebSocket) {
                        return new WebSocket(location);
                    } else {
                        return new MozWebSocket(location);
                    }
                }
            }

to

 function _getWebSocket(location) {
                if (_request.webSocketCreator != null) {
                    return _request.webSocketCreator(location);
                } else if (_request.webSocketImpl != null) {
                    return _request.webSocketImpl;
                } else {
                    if (window.WebSocket) {
                        return new WebSocket(location);
                    } else {
                        return new MozWebSocket(location);
                    }
                }
            }

which allowed me to specify a creation function in my request which would create WebSocket-objects with the correct URL. Example

        var request = {
            url: '/live',
            ...
            webSocketCreator : function(location) { return new WebSocketImplementation(location); },
           ...
      }
@jfarcand
Copy link
Member

Salut, like the idea. I will add it to 1.0.5, which will be release this week (or early next week). Do you have a sample I could play with as well? Thanks

jfarcand added a commit that referenced this issue Nov 19, 2012
@flowersinthesand
Copy link
Member

I disagree. If you found deviated behaviors from the fallback, comparing to the spec, then the problem is in the fallback. It is more desirable to file an issue to someone who writes the fallback.

@jfarcand jfarcand reopened this Nov 20, 2012
jfarcand added a commit that referenced this issue Dec 7, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants