Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed VIM freezes & support UTF-8 #15

Closed
zlhgo opened this issue Aug 5, 2014 · 1 comment
Closed

fixed VIM freezes & support UTF-8 #15

zlhgo opened this issue Aug 5, 2014 · 1 comment

Comments

@zlhgo
Copy link

zlhgo commented Aug 5, 2014

thanks,aluzzardi.
sorry everyboy for my english.

diff --git a/wssh/server.py b/wssh/server.py
index 17a4965..b334477 100644
--- a/wssh/server.py
+++ b/wssh/server.py
@@ -118,19 +118,26 @@ class WSSHBridge(object):
                         data['resize'].get('width', 80),
                         data['resize'].get('height', 24))
                 if 'data' in data:
-                    channel.send(data['data'])
+                    channel.send(data['data'].encode('utf-8'))
         finally:
             self.close()

     def _forward_outbound(self, channel):
         """ Forward outbound traffic (ssh -> websockets) """
         try:
+            data = ''
             while True:
                 wait_read(channel.fileno())
-                data = channel.recv(1024)
-                if not len(data):
+                recv = channel.recv(1024)
+                if not len(recv):
                     return
-                self._websocket.send(json.dumps({'data': data}))
+                
+                data += recv
+                try:
+                    self._websocket.send(json.dumps({'data':data}))
+                    data = ''
+                except UnicodeDecodeError:
+                    pass
         finally:
             self.close()

diff --git a/wssh/static/term.js b/wssh/static/term.js
index 9489334..20883bf 100644
--- a/wssh/static/term.js
+++ b/wssh/static/term.js
@@ -129,9 +129,10 @@ function Terminal(cols, rows, handler) {

   this.cols = cols || Terminal.geometry[0];
   this.rows = rows || Terminal.geometry[1];
-
-  if (handler) {
-    this.on('data', handler);
+  this.handler = handler;
+  
+  if (this.handler) {
+    this.on('data', this.handler);
   }

   this.ybase = 0;
@@ -2432,7 +2433,7 @@ Terminal.prototype.reverseIndex = function() {

 // ESC c Full Reset (RIS).
 Terminal.prototype.reset = function() {
-  Terminal.call(this, this.cols, this.rows);
+  Terminal.call(this, this.cols, this.rows, this.handler);
   this.refresh(0, this.rows - 1);
 };

@zlhgo zlhgo closed this as completed Aug 5, 2014
@zlhgo zlhgo reopened this Aug 5, 2014
@zlhgo zlhgo closed this as completed Aug 5, 2014
@zlhgo zlhgo reopened this Aug 5, 2014
@zlhgo zlhgo closed this as completed Sep 4, 2014
@jumpserver
Copy link

I try this patch, but when I login, I can't find the term anymore

sbuss pushed a commit to sbuss/wssh that referenced this issue Nov 21, 2015
sbuss added a commit to sbuss/wssh that referenced this issue Nov 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant