auto-sync: 2026-05-17 06:12:59
This commit is contained in:
+5
-1
@@ -71,7 +71,7 @@ class SSEBroker:
|
||||
(client_id, queue)
|
||||
"""
|
||||
cid = client_id or str(uuid.uuid4())
|
||||
queue: asyncio.Queue = asyncio.Queue(maxsize=100)
|
||||
queue = asyncio.Queue(maxsize=100)
|
||||
self._subscribers[cid] = queue
|
||||
|
||||
# 发送历史事件
|
||||
@@ -83,6 +83,10 @@ class SSEBroker:
|
||||
|
||||
return cid, queue
|
||||
|
||||
async def subscribe_async(self, client_id: Optional[str] = None) -> tuple:
|
||||
"""异步订阅(在 async 上下文中调用)"""
|
||||
return self.subscribe(client_id)
|
||||
|
||||
def unsubscribe(self, client_id: str) -> None:
|
||||
if client_id in self._subscribers:
|
||||
del self._subscribers[client_id]
|
||||
|
||||
Reference in New Issue
Block a user