From c6633dae0e1886ac415dcb74fa0b2bde1ea48e66 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sun, 14 Sep 2014 23:37:56 -0400 Subject: introduce a pubsub system for communication --- termcast.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'termcast.py') 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")) -- cgit v1.2.3-54-g00ecf