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

[enh] #58 new method receive_json in WSConnection class

parent 89067c11
No related branches found
No related tags found
No related merge requests found
......@@ -129,7 +129,7 @@ class WSConnection:
await self.connection.send_str(data)
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
......@@ -141,6 +141,18 @@ class WSConnection:
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):
"""
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.
Please register or to comment