(self, message)
| 520 | self._send_spontaneous_websocket_message(msg) |
| 521 | |
| 522 | def _send_spontaneous_websocket_message(self, message): |
| 523 | for ws in list(self.websockets): |
| 524 | # noinspection PyBroadException |
| 525 | try: |
| 526 | if ws.send_message(message): |
| 527 | #if message sent ok, continue with next client |
| 528 | continue |
| 529 | except Exception: |
| 530 | self._log.error("sending websocket spontaneous message", exc_info=True) |
| 531 | |
| 532 | self._log.debug("removing websocket instance, communication error with client") |
| 533 | #here arrives if the message was not sent ok, then the client is removed |
| 534 | try: |
| 535 | self.websockets.remove(ws) |
| 536 | except Exception: |
| 537 | pass # happens when there are multiple clients |
| 538 | else: |
| 539 | ws.close(terminate_server=False) |
| 540 | |
| 541 | def execute_javascript(self, code): |
| 542 | self._send_spontaneous_websocket_message(_MSG_JS + code) |
no test coverage detected