Explorar o código

ensure we do not emit to relay if disconnected

Rodja Trappe hai 1 ano
pai
achega
a34fb32fe4
Modificáronse 1 ficheiros con 2 adicións e 1 borrados
  1. 2 1
      nicegui/air.py

+ 2 - 1
nicegui/air.py

@@ -138,4 +138,5 @@ class Air:
         await self.relay.disconnect()
         await self.relay.disconnect()
 
 
     async def emit(self, message_type: str, data: Dict[str, Any], room: str) -> None:
     async def emit(self, message_type: str, data: Dict[str, Any], room: str) -> None:
-        await self.relay.emit('forward', {'event': message_type, 'data': data, 'room': room})
+        if self.relay.connected:
+            await self.relay.emit('forward', {'event': message_type, 'data': data, 'room': room})