diff options
author | Jesse Luehrs <doy@tozt.net> | 2014-09-17 12:40:07 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2014-09-17 12:40:07 -0400 |
commit | 95d3a2ef4001473aa382eafea2ed00a066973c11 (patch) | |
tree | c82ce766bb9334ef94ce9fbb1e96f84aef081f1c | |
parent | 92ba955c9cb5836c21d15537f9cccc91a999bc53 (diff) | |
download | python-termcast-server-95d3a2ef4001473aa382eafea2ed00a066973c11.tar.gz python-termcast-server-95d3a2ef4001473aa382eafea2ed00a066973c11.zip |
report the number of viewers in the selection menu
-rw-r--r-- | ssh.py | 10 | ||||
-rw-r--r-- | termcast.py | 4 |
2 files changed, 10 insertions, 4 deletions
@@ -98,8 +98,8 @@ class Connection(object): def _display_streamer_screen(self, streamers): self.chan.send("\033[H\033[2JWelcome to Termcast!") self.chan.send( - "\033[3H %-20s %-15s %-15s %-15s" % ( - "User", "Terminal size", "Idle time", "Total time" + "\033[3H %-20s %-15s %-10s %-15s %-15s" % ( + "User", "Terminal size", "Viewers", "Idle time", "Total time" ) ) row = 4 @@ -112,11 +112,13 @@ class Connection(object): if streamer["cols"] > self.server.cols or streamer["rows"] > self.server.rows: size_pre = "\033[31m" size_post = "\033[m" + viewers = streamer["viewers"] idle = streamer["idle_time"] total = streamer["total_time"] self.chan.send( - "\033[%dH%s) %-20s %s%-15s%s %-15s %-15s" % ( - row, key, name, size_pre, size, size_post, idle, total + "\033[%dH%s) %-20s %s%-15s%s %-10s %-15s %-15s" % ( + row, key, name, size_pre, size, size_post, + viewers, idle, total ) ) row += 1 diff --git a/termcast.py b/termcast.py index 1a6beb7..3363365 100644 --- a/termcast.py +++ b/termcast.py @@ -94,6 +94,7 @@ class Connection(object): self.client = client self.connection_id = connection_id self.publisher = publisher + self.viewers = 0 def run(self): buf = b'' @@ -144,11 +145,13 @@ class Connection(object): def msg_new_viewer(self, connection_id): if connection_id != self.connection_id: return + self.viewers += 1 self.publisher.notify("new_data", self.connection_id, self.handler.buf, b'') self.client.send(b"msg watcher connected\n") def msg_viewer_disconnect(self, connection_id): self.client.send(b"msg watcher disconnected\n") + self.viewers -= 1 def request_get_streamers(self): return { @@ -158,4 +161,5 @@ class Connection(object): "cols": self.handler.cols, "idle_time": self.handler.idle_time(), "total_time": self.handler.total_time(), + "viewers": self.viewers, } |