aboutsummaryrefslogtreecommitdiffstats
path: root/termcast.py
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2014-09-14 23:37:56 -0400
committerJesse Luehrs <doy@tozt.net>2014-09-14 23:37:56 -0400
commitc6633dae0e1886ac415dcb74fa0b2bde1ea48e66 (patch)
treeef27b560671ac1f7c1cac7ec91c027e8bff020ef /termcast.py
parent033673ac065a189bc611af689c964a7f75a3a183 (diff)
downloadpython-termcast-server-c6633dae0e1886ac415dcb74fa0b2bde1ea48e66.tar.gz
python-termcast-server-c6633dae0e1886ac415dcb74fa0b2bde1ea48e66.zip
introduce a pubsub system for communication
Diffstat (limited to 'termcast.py')
-rw-r--r--termcast.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/termcast.py b/termcast.py
index aea056c..c701f6a 100644
--- a/termcast.py
+++ b/termcast.py
@@ -24,10 +24,12 @@ class Handler(object):
return term[:-1]
class Connection(object):
- def __init__(self, client, connection_id):
+ def __init__(self, client, connection_id, publisher):
self.client = client
+ self.connection_id = connection_id
+ self.publisher = publisher
- def run(self, ssh_connections):
+ def run(self):
buf = b''
while len(buf) < 1024 and b"\n" not in buf:
buf += self.client.recv(1024)
@@ -69,3 +71,10 @@ class Connection(object):
self.handler.process(buf)
else:
return
+
+ def msg_new_viewer(self, sock, connection_id):
+ # XXX restore this once we start passing in meaningful connection ids
+ # if connection_id != self.connection_id:
+ # return
+ term_contents = self.handler.get_term()
+ sock.send(term_contents.replace("\n", "\r\n"))