(self, data: Any)
| 283 | self._task = None |
| 284 | |
| 285 | async def pub(self, data: Any): |
| 286 | # Publish a message |
| 287 | if not self._pub_socket: |
| 288 | ep = f"{self.endpoint.protocol}://{self.endpoint.address}" |
| 289 | self._pub_socket = self.context.socket(zmq.PUB) |
| 290 | self._pub_socket.bind(ep) |
| 291 | await asyncio.sleep(0.05) |
| 292 | |
| 293 | msg = Message(payload=data) |
| 294 | async with self.lock: |
| 295 | await self._pub_socket.send(msg.serialize()) |
| 296 | |
| 297 | async def sub(self, callback: Callable[[Message], Any]): |
| 298 | # Subscribe and handle messages |