diff --git a/duniterpy/api/client.py b/duniterpy/api/client.py index 4f2df1225dd4cae53d8dc40d4c3f8e7b463a7090..78612071930c0f92a11e1c641a57e2c90af6039a 100644 --- a/duniterpy/api/client.py +++ b/duniterpy/api/client.py @@ -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