def open(type, token, socket): global connId if type == "storager" and not CBUtil.checkToken(token): socket.write_message(json.dumps({"action": "close", "type": "invalidToken"})) socket.close() return connId += 1 socket.id = connId addConn(SocketData(connId, token, socket, type))
def on_message(self, message): if not CBUtil.isJson(message): return msg = json.loads(message) me = SocketHandler.getConn(self.id) sid = -1 if "sid" in msg: if not me.inSids(msg["sid"]): return sid = me.getSid(msg["sid"]) SocketHandler.message(me, msg, sid)
def open(type, token, socket): global connId if type == "storager" and not CBUtil.checkToken(token): socket.write_message( json.dumps({ "action": "close", "type": "invalidToken" })) socket.close() return connId += 1 socket.id = connId addConn(SocketData(connId, token, socket, type))