def on_open(ws): Utils.log("### open ###") message = { "type": "join_channel", "channel": "paintboard", "channel_param": "" } ws.send(json.dumps(message))
def check_loop(self): while True: try: self.check() Utils.log("[Board check] ok") except: Utils.log("[Board check] failed") time.sleep(Const.BOARD_check_interval)
def draw(self, x, y, color): data = {"x": x, "y": y, "color": color} r = self.ss.post(Const.URL_paint, data) if r.status_code == 200: self.last_upd_time = datetime.now().timestamp() Utils.log("[OK]", self.uid, data, r.text, self.last_upd_time) return True Utils.log("[Fail]", self.uid, data, r.status_code, r.text) return False
def on_close(ws): Utils.log("### closed ###")
def on_error(ws, error): Utils.log("### error ###") Utils.log(error) connect()
def count_loop(self): while True: Utils.log("[Count]", len(self.pixels)) time.sleep(Const.MGR_count_interval)
def del_pixel(self, px): if px in self.pixels: self.pixels.remove(px) Utils.log("[Del]", px)
def add_pixel(self, px): if px not in self.pixels: self.pixels.append(px) Utils.log("[Add]", px)