aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2014-09-15 00:56:06 -0400
committerJesse Luehrs <doy@tozt.net>2014-09-15 00:56:06 -0400
commite820f9c4a7bcf887d77eb0df8946a59f32313e61 (patch)
tree9f3ae267dbb1caf3b20b09efe711992b2d6020f6
parenta306d46a1ee07504b56f8f1115b8693fdf7b92b5 (diff)
downloadpython-termcast-server-e820f9c4a7bcf887d77eb0df8946a59f32313e61.tar.gz
python-termcast-server-e820f9c4a7bcf887d77eb0df8946a59f32313e61.zip
actually broadcast the data being received
-rw-r--r--ssh.py19
-rw-r--r--termcast.py6
2 files changed, 18 insertions, 7 deletions
diff --git a/ssh.py b/ssh.py
index 127f1d7..b2d4a6d 100644
--- a/ssh.py
+++ b/ssh.py
@@ -16,18 +16,29 @@ class Connection(object):
self.transport.add_server_key(paramiko.RSAKey(filename='test_rsa.key'))
self.connection_id = connection_id
self.publisher = publisher
+ self.initialized = False
def run(self):
self.transport.start_server(server=Server())
- chan = self.transport.accept(None)
+ self.chan = self.transport.accept(None)
# XXX need to have the user select a stream, and then pass the stream's
# id in here
- contents = self.publisher.request_one("new_viewer", "some-random-id")
- chan.send(contents)
+ self.publisher.notify("new_viewer", "some-stream")
time.sleep(5)
- chan.close()
+ self.chan.close()
+
+ def msg_new_data(self, connection_id, prev_buf, data):
+ # XXX uncomment this once we implement stream selection
+ # if self.watching_id != connection_id:
+ # return
+
+ if not self.initialized:
+ self.chan.send(prev_buf)
+ self.initialized = True
+
+ self.chan.send(data)
class Server(paramiko.ServerInterface):
def check_channel_request(self, kind, chanid):
diff --git a/termcast.py b/termcast.py
index fcc43c6..c1d8a5e 100644
--- a/termcast.py
+++ b/termcast.py
@@ -71,13 +71,13 @@ class Connection(object):
while True:
buf = self.client.recv(1024)
if len(buf) > 0:
+ self.publisher.notify("new_data", self.connection_id, self.handler.buf, buf)
self.handler.process(buf)
else:
return
- def request_new_viewer(self, connection_id):
+ def msg_new_viewer(self, 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()
- return term_contents.replace("\n", "\r\n")
+ self.publisher.notify("new_data", self.connection_id, self.handler.buf, b'')