def send_ping(self, ws): msg_id = 0 while not self.exit_all: try: msg = '{"type":"ping","call_id":%d}' % msg_id Logger.log_bc_ws(">>> %s" % msg) ws.send(msg) msg_id += 1 time.sleep(5) except Exception as exc: Logger.log("[send_ping]catch exception: %s" % str(exc)) break
def server_loop(self, ws): while not self.exit_all: result = ws.recv() if len(result): self.connect_live = True data = json.loads(result) Logger.log_bc_ws("<<< %s" % result) self.handle_msg(data) else: Logger.log("recv empty msg, connected: ", ws.connected) if not ws.connected: Logger.log("**=** recv empty msg, ws conn may be kicked by bc server") break
def test_logger_log_bc_ws(self): Logger.log_bc_ws("testunit: bearychat websocket hello test")