Fix #976: Add support for websocket send_json and receive_json#984
Fix #976: Add support for websocket send_json and receive_json#984asvetlov merged 8 commits intoaio-libs:masterfrom
Conversation
| type(data)) | ||
| self._writer.send(data, binary=True) | ||
|
|
||
| def send_json(self, data, *, dumps=json.dumps): |
There was a problem hiding this comment.
Please call .send_str() instead of working on low level.
|
Would you add tests also? |
|
Yes I will |
|
@asvetlov what I can do to avoid I am using Also, do you have some suggestions for the tests I wrote? |
aiohttp/web_ws.py
Outdated
| self._writer.send(data, binary=True) | ||
|
|
||
| def send_json(self, data, *, dumps=json.dumps): | ||
| if self._writer is None: |
There was a problem hiding this comment.
These checks are not required: .send_str() performs them anyway.
There is no need to do the check twice.
|
@asvetlov I've noticed that in |
|
I think yes. |
|
@asvetlov I have added all the methods discussed above, now we have:
both on |
|
Thanks! |
What do these changes do?
Add support for websocket server to send json and for websocket client to send and receive json
Are there changes in behavior for the user?
User can use methods:
send_jsonandreceive_jsonboth on websocket server and clientRelated issue number
#976
Checklist