def _Get_Ping(self, delay_time): loop_times = int(delay_time / 15) for time in range(loop_times): ping = yield from self.ws.recv() print(ping) yield from self.ws.send(Request.Pong()) print(Request.Pong())
def _Subscribe_Order_Book(self, crypto, money, subscribe, depth, delay_time): # Let the connecting coroutine connect first. So sleep awhile. yield from asyncio.sleep(3) yield from self.ws.send( Request.Order_Book(crypto=crypto, money=money, subscribe=subscribe, depth=depth)) for count in range(100): print(count) result_json = yield from self.ws.recv() result = json.loads(result_json) print(result) yield from self.ws.send(Request.Pong()) yield from asyncio.sleep(delay_time) self.loop.stop()