-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Add json convenience methods to websocket message objects #897
Conversation
@asvetlov is there auto-documentation for the |
45f36e8
to
d1438b6
Compare
@@ -69,6 +69,15 @@ | |||
MSG_SIZE = 2 ** 14 | |||
|
|||
|
|||
MessageBase = collections.namedtuple('Message', ['tp', 'data', 'extra']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use _MessageBase
name
Yes, it is: http://aiohttp.readthedocs.io/en/stable/api.html#aiohttp.websocket.Message
|
Sure, are you targeting version |
aiohttp 0.22 was not released yet :) |
👍 bumping back to 0.22 |
@@ -285,6 +285,15 @@ def receive_bytes(self): | |||
msg.data)) | |||
return msg.data | |||
|
|||
@asyncio.coroutine | |||
def receive_json(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Signature should be def receive_json(self, *, loads=json.loads)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, good catch.
Thanks! |
Resolves #862
This change adds a
json
method to theaiohttp.websocket.Message
object and areceive_json
coroutine method to theaiohttp.web_ws.WebSocketResponse
object.