Revert "change demo to utf8 input"

This reverts commit e6e5ecc0f2.
This commit is contained in:
Jörg Breitbart
2019-05-12 22:17:06 +02:00
parent 06c292c11d
commit c0e9bbe87f
3 changed files with 6 additions and 13 deletions
-1
View File
@@ -143,7 +143,6 @@ function createTerminal(): void {
pid = processId;
socketURL += processId;
socket = new WebSocket(socketURL);
socket.binaryType = 'arraybuffer';
socket.onopen = runRealTerminal;
socket.onclose = runFakeTerminal;
socket.onerror = runFakeTerminal;
+6 -7
View File
@@ -36,8 +36,7 @@ function startServer() {
cols: cols || 80,
rows: rows || 24,
cwd: process.env.PWD,
env: process.env,
encoding: null
env: process.env
});
console.log('Created terminal with PID: ' + term.pid);
@@ -67,20 +66,20 @@ function startServer() {
ws.send(logs[term.pid]);
function buffer(socket, timeout) {
let buffer = [];
let s = '';
let sender = null;
return (data) => {
buffer.push(data);
s += data;
if (!sender) {
sender = setTimeout(() => {
socket.send(Buffer.concat(buffer));
buffer = [];
socket.send(s);
s = '';
sender = null;
}, timeout);
}
};
}
const send = buffer(ws, 5);
const send = buffer(ws, 5);
term.on('data', function(data) {
try {
-5
View File
@@ -42,11 +42,6 @@ export function attach(term: Terminal, socket: WebSocket, bidirectional: boolean
addonTerminal.__getMessage = function(ev: MessageEvent): void {
let str: string;
if (ev.data instanceof ArrayBuffer) {
addonTerminal.writeUtf8(new Uint8Array(ev.data));
return;
}
if (typeof ev.data === 'object') {
if (!myTextDecoder) {
myTextDecoder = new TextDecoder();