Beispiel #1
0
 def on_open(ws):
     Utils.log("### open ###")
     message = {
         "type": "join_channel",
         "channel": "paintboard",
         "channel_param": ""
     }
     ws.send(json.dumps(message))
Beispiel #2
0
 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
Beispiel #4
0
 def on_close(ws):
     Utils.log("### closed ###")
Beispiel #5
0
 def on_error(ws, error):
     Utils.log("### error ###")
     Utils.log(error)
     connect()
Beispiel #6
0
 def count_loop(self):
     while True:
         Utils.log("[Count]", len(self.pixels))
         time.sleep(Const.MGR_count_interval)
Beispiel #7
0
 def del_pixel(self, px):
     if px in self.pixels:
         self.pixels.remove(px)
         Utils.log("[Del]", px)
Beispiel #8
0
 def add_pixel(self, px):
     if px not in self.pixels:
         self.pixels.append(px)
         Utils.log("[Add]", px)