From a8c3374214aed00a131b7a6fe3c5ee158d0ceba4 Mon Sep 17 00:00:00 2001 From: Arama Date: Thu, 19 Dec 2024 19:29:38 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=87=8D=E6=96=B0=E6=B7=BB=E5=8A=A0=5F?= =?UTF-8?q?=5Fanext=5F=5F=E5=88=B0Connection?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/steam/core/connection.py | 42 ++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/steam/core/connection.py b/src/steam/core/connection.py index 40639ab..3562284 100644 --- a/src/steam/core/connection.py +++ b/src/steam/core/connection.py @@ -27,7 +27,7 @@ class Connection: @property def local_address(self): - return self._stream_writer.get_extra_info('sockname')[0] + raise NotImplementedError async def connect(self, server_addr): raise NotImplementedError @@ -48,7 +48,7 @@ async def disconnect(self): self._readbuf = b'' self.send_queue._queue.clear() self.recv_queue._queue.clear() - await self.recv_queue.put(StopIteration) + await self.recv_queue.put(StopAsyncIteration) if self._stream_writer: logger.debug('wait close') @@ -57,12 +57,14 @@ async def disconnect(self): logger.debug('Disconnected.') - async def __aiter__(self): - while True: - result = await self.recv_queue.get() - if result is StopIteration: - raise StopAsyncIteration - yield result + def __aiter__(self): + return self + + async def __anext__(self): + result = await self.recv_queue.get() + if result is StopAsyncIteration: + raise result + return result async def put_message(self, message): await self.send_queue.put(message) @@ -81,6 +83,10 @@ class TCPConnection(Connection): FMT = '