Reputation: 69
I have a c++ server that use libssh to create a Linux shell. I send Linux commands from a javascript client application in a browser for example 'ls' or 'pwd' ecc ecc. to the c++ server by websockets, then I write the command in the libssh buffer followed by /n and a thread get the replay. I write the replay in a Json structure and by websockets again send it to the web client. Then I show the replay in a textarea and if the replay is plain ascii all is ok. Obviously replays to commands like nano doesn't work. So I would like javascript terminal emulators like Xterm. But every example connect it to socket.io or node.pty. I tried to use directly write but nothing is showed. How it's possible to connect Xterm.js to websockets or visualize a generic string?
Upvotes: 4
Views: 8246
Reputation: 101
xterm.js provides an 'addOn' that makes connecting to a websocket very easy. There is a very simplified example on this page that can help get you started, I believe.
https://xtermjs.org/docs/api/addons/attach/
Upvotes: 9