Explorar el Código

Add rudimentary room usage reporting

niels hace 4 años
padre
commit
8d685e1320
Se han modificado 1 ficheros con 3 adiciones y 0 borrados
  1. 3 0
      chube.py

+ 3 - 0
chube.py

@@ -336,12 +336,15 @@ async def on_connect(ws, path):
         rooms[path] = Room()
     room = rooms[path]
     room.channel.subscribe(ws)
+    print("Currently {} user{} are using room {}".format(len(room.channel.subscribers),"s" if len(room.channel.subscribers) != 1 else "", path))
 
 
 async def on_disconnect(ws, path):
     room = rooms[path]
     room.channel.unsubscribe(ws)
     await release_control(ws, room)
+    print("Currently {} user{} are using room {}".format(len(room.channel.subscribers),"s" if len(room.channel.subscribers) != 1 else "", path))
+
 
 
 def make_resolver():