Skip to content
Snippets Groups Projects
Commit 6558cfab authored by Vincent Texier's avatar Vincent Texier Committed by Vincent Texier
Browse files

[enh] #58 new method receive_json in WSConnection class

parent d31e9f6f
No related branches found
No related tags found
2 merge requests!94Merge dev into master for release 0.56.0,!84#58: WS2P support
...@@ -129,7 +129,7 @@ class WSConnection: ...@@ -129,7 +129,7 @@ class WSConnection:
await self.connection.send_str(data) await self.connection.send_str(data)
return None return None
async def receive_str(self, timeout: Optional[float] = None) -> Optional[str]: async def receive_str(self, timeout: Optional[float] = None) -> str:
""" """
Wait for a data string from the web socket connection Wait for a data string from the web socket connection
...@@ -141,6 +141,18 @@ class WSConnection: ...@@ -141,6 +141,18 @@ class WSConnection:
return await self.connection.receive_str(timeout=timeout) return await self.connection.receive_str(timeout=timeout)
async def receive_json(self, timeout: Optional[float] = None) -> Any:
"""
Wait for json data from the web socket connection
:param timeout: Timeout in seconds
:return:
"""
if self.connection is None:
raise Exception("Connection property is empty")
return await self.connection.receive_json(timeout=timeout)
async def init_connection(self): async def init_connection(self):
""" """
Mandatory for aiohttp library to avoid the use of the with statement Mandatory for aiohttp library to avoid the use of the with statement
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment