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

Compatibility with WebSockets 3.0 #15

Closed
TomOudeNijhuis opened this issue Feb 3, 2016 · 2 comments
Closed

Compatibility with WebSockets 3.0 #15

TomOudeNijhuis opened this issue Feb 3, 2016 · 2 comments
Assignees

Comments

@TomOudeNijhuis
Copy link

I suppose support for the ConnectionClosed exception needs to be implemented in WebsocketConnectionView. See websockets changelog: https://websockets.readthedocs.org/en/stable/changelog.html

I updated the code as followed:

from websockets.exceptions import ConnectionClosed

@asyncio.coroutine
def __call__(self, ws):
    self.ws = ws
    yield from self.on_open()

    while True:
        try:
            message = yield from self.ws.recv()

            if message is None:
                yield from self.on_close()
                break

            yield from self.on_message(message)

        except ConnectionClosed:
            yield from self.on_close()
            break

Would this be a suitable solution?

@housleyjk housleyjk self-assigned this Feb 3, 2016
@housleyjk
Copy link
Owner

That works for the class-based websocket, but it doesn't protect code that uses the function approach. I should have a fix for this out later today.

@TomOudeNijhuis
Copy link
Author

Thank you very much for your quick response. I will try your new version later today.

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

No branches or pull requests

2 participants