araeyn commited on
Commit
e612cc6
·
verified ·
1 Parent(s): dc58310

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -4
app.py CHANGED
@@ -19,13 +19,12 @@ async def echo(websocket):
19
  p = json.load(open("p.json"))
20
  if jm["type"] == "login":
21
  if jm["token"] not in p.keys():
22
- p.update({jm["token"]: {"pos": {"x": 0,"y": 0, "vy": 0}, "time": time.time() * 1000}})
23
- json.dump(p, open("p.json", "w"))
 
24
  await websocket.send(json.dumps({"type": "init", "data": p[jm["token"]]}))
25
  elif jm["type"] == "update":
26
  if time.time() * 1000 - p[jm["token"]]["time"] >= 1000:
27
- p[jm["token"]]["time"] = time.time() * 1000
28
- json.dump(p, open("p.json", "w"))
29
  await websocket.send(json.dumps({"type": "reconnect"}))
30
  return
31
  p.update({jm["token"]: jm["data"]})
 
19
  p = json.load(open("p.json"))
20
  if jm["type"] == "login":
21
  if jm["token"] not in p.keys():
22
+ p.update({jm["token"]: {"pos": {"x": 0,"y": 0, "vy": 0}}})
23
+ p[jm["token"]]["time"] = time.time() * 1000
24
+ json.dump(p, open("p.json", "w"))
25
  await websocket.send(json.dumps({"type": "init", "data": p[jm["token"]]}))
26
  elif jm["type"] == "update":
27
  if time.time() * 1000 - p[jm["token"]]["time"] >= 1000:
 
 
28
  await websocket.send(json.dumps({"type": "reconnect"}))
29
  return
30
  p.update({jm["token"]: jm["data"]})