aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2019-11-22 08:19:22 -0500
committerJesse Luehrs <doy@tozt.net>2019-11-22 08:19:22 -0500
commit427375e2bef72f827e42814f5770265598c4a5eb (patch)
tree14bdc24e92e75d44b28c20f8d682bc588e42c423
parent6bb00f299cf553fd7f143f0bc3c85bd6107cc7aa (diff)
downloadteleterm-427375e2bef72f827e42814f5770265598c4a5eb.tar.gz
teleterm-427375e2bef72f827e42814f5770265598c4a5eb.zip
parse the websocket message in the browser
-rw-r--r--teleterm-web/src/lib.rs13
-rw-r--r--teleterm-web/src/protocol.rs7
-rw-r--r--teleterm/static/teleterm_web.js73
-rw-r--r--teleterm/static/teleterm_web_bg.wasmbin395219 -> 402627 bytes
4 files changed, 58 insertions, 35 deletions
diff --git a/teleterm-web/src/lib.rs b/teleterm-web/src/lib.rs
index 812845f..030ac45 100644
--- a/teleterm-web/src/lib.rs
+++ b/teleterm-web/src/lib.rs
@@ -1,5 +1,6 @@
mod model;
mod prelude;
+mod protocol;
mod ws;
use crate::prelude::*;
@@ -53,6 +54,18 @@ fn update(
}
ws::WebSocketEvent::Message(msg) => {
log::info!("{}: message: {:?}", id, msg);
+ let json = msg.data().as_string().unwrap();
+ let msg: crate::protocol::Message =
+ serde_json::from_str(&json).unwrap();
+ match msg {
+ crate::protocol::Message::TerminalOutput { data } => {
+ log::info!(
+ "{}: got bytes: {}",
+ id,
+ String::from_utf8_lossy(&data)
+ );
+ }
+ }
}
ws::WebSocketEvent::Error(e) => {
log::error!("{}: error: {:?}", id, e);
diff --git a/teleterm-web/src/protocol.rs b/teleterm-web/src/protocol.rs
new file mode 100644
index 0000000..d9f3a8e
--- /dev/null
+++ b/teleterm-web/src/protocol.rs
@@ -0,0 +1,7 @@
+// it's possible we should just consider pulling the real protocol out into a
+// crate or something? but ideally in a way that doesn't require pulling in
+// tokio
+#[derive(Debug, Clone, PartialEq, Eq, serde::Deserialize)]
+pub enum Message {
+ TerminalOutput { data: Vec<u8> },
+}
diff --git a/teleterm/static/teleterm_web.js b/teleterm/static/teleterm_web.js
index 1e7dfec..ffeb4a4 100644
--- a/teleterm/static/teleterm_web.js
+++ b/teleterm/static/teleterm_web.js
@@ -1,10 +1,6 @@
let wasm;
-function __wbg_elem_binding0(arg0, arg1, arg2) {
- wasm.__wbg_function_table.get(47)(arg0, arg1, arg2);
-}
-
const heap = new Array(32);
heap.fill(undefined);
@@ -21,29 +17,32 @@ function addHeapObject(obj) {
heap[idx] = obj;
return idx;
}
+function __wbg_elem_binding0(arg0, arg1, arg2) {
+ wasm.__wbg_function_table.get(41)(arg0, arg1, addHeapObject(arg2));
+}
function __wbg_elem_binding1(arg0, arg1, arg2) {
- wasm.__wbg_function_table.get(42)(arg0, arg1, addHeapObject(arg2));
+ wasm.__wbg_function_table.get(41)(arg0, arg1, addHeapObject(arg2));
}
-function __wbg_elem_binding2(arg0, arg1, arg2) {
- wasm.__wbg_function_table.get(42)(arg0, arg1, addHeapObject(arg2));
+function __wbg_elem_binding2(arg0, arg1) {
+ wasm.__wbg_function_table.get(195)(arg0, arg1);
}
function __wbg_elem_binding3(arg0, arg1, arg2) {
- wasm.__wbg_function_table.get(42)(arg0, arg1, addHeapObject(arg2));
+ wasm.__wbg_function_table.get(46)(arg0, arg1, arg2);
}
-function __wbg_elem_binding4(arg0, arg1) {
- wasm.__wbg_function_table.get(188)(arg0, arg1);
+function __wbg_elem_binding4(arg0, arg1, arg2) {
+ wasm.__wbg_function_table.get(265)(arg0, arg1, addHeapObject(arg2));
}
function __wbg_elem_binding5(arg0, arg1, arg2) {
- wasm.__wbg_function_table.get(42)(arg0, arg1, addHeapObject(arg2));
+ wasm.__wbg_function_table.get(41)(arg0, arg1, addHeapObject(arg2));
}
function __wbg_elem_binding6(arg0, arg1, arg2) {
- wasm.__wbg_function_table.get(258)(arg0, arg1, addHeapObject(arg2));
+ wasm.__wbg_function_table.get(41)(arg0, arg1, addHeapObject(arg2));
}
function __wbg_elem_binding7(arg0, arg1, arg2, arg3, arg4) {
- wasm.__wbg_function_table.get(285)(arg0, arg1, addHeapObject(arg2), arg3, addHeapObject(arg4));
+ wasm.__wbg_function_table.get(292)(arg0, arg1, addHeapObject(arg2), arg3, addHeapObject(arg4));
}
function __wbg_elem_binding8(arg0, arg1, arg2, arg3) {
- wasm.__wbg_function_table.get(289)(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
+ wasm.__wbg_function_table.get(296)(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
}
/**
*/
@@ -572,6 +571,10 @@ function init(module) {
handleError(e)
}
};
+ imports.wbg.__widl_f_data_MessageEvent = function(arg0) {
+ const ret = getObject(arg0).data;
+ return addHeapObject(ret);
+ };
imports.wbg.__widl_instanceof_Node = function(arg0) {
const ret = getObject(arg0) instanceof Node;
return ret;
@@ -881,7 +884,7 @@ function init(module) {
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
throw new Error(getStringFromWasm(arg0, arg1));
};
- imports.wbg.__wbindgen_closure_wrapper213 = function(arg0, arg1, arg2) {
+ imports.wbg.__wbindgen_closure_wrapper232 = function(arg0, arg1, arg2) {
const state = { a: arg0, b: arg1, cnt: 1 };
const real = (arg0) => {
state.cnt++;
@@ -890,7 +893,7 @@ function init(module) {
try {
return __wbg_elem_binding3(a, state.b, arg0);
} finally {
- if (--state.cnt === 0) wasm.__wbg_function_table.get(43)(a, state.b);
+ if (--state.cnt === 0) wasm.__wbg_function_table.get(42)(a, state.b);
else state.a = a;
}
}
@@ -899,16 +902,16 @@ function init(module) {
const ret = real;
return addHeapObject(ret);
};
- imports.wbg.__wbindgen_closure_wrapper221 = function(arg0, arg1, arg2) {
+ imports.wbg.__wbindgen_closure_wrapper541 = function(arg0, arg1, arg2) {
const state = { a: arg0, b: arg1, cnt: 1 };
- const real = (arg0) => {
+ const real = () => {
state.cnt++;
const a = state.a;
state.a = 0;
try {
- return __wbg_elem_binding5(a, state.b, arg0);
+ return __wbg_elem_binding2(a, state.b, );
} finally {
- if (--state.cnt === 0) wasm.__wbg_function_table.get(43)(a, state.b);
+ if (--state.cnt === 0) wasm.__wbg_function_table.get(196)(a, state.b);
else state.a = a;
}
}
@@ -917,16 +920,16 @@ function init(module) {
const ret = real;
return addHeapObject(ret);
};
- imports.wbg.__wbindgen_closure_wrapper930 = function(arg0, arg1, arg2) {
+ imports.wbg.__wbindgen_closure_wrapper949 = function(arg0, arg1, arg2) {
const state = { a: arg0, b: arg1, cnt: 1 };
const real = (arg0) => {
state.cnt++;
const a = state.a;
state.a = 0;
try {
- return __wbg_elem_binding6(a, state.b, arg0);
+ return __wbg_elem_binding4(a, state.b, arg0);
} finally {
- if (--state.cnt === 0) wasm.__wbg_function_table.get(259)(a, state.b);
+ if (--state.cnt === 0) wasm.__wbg_function_table.get(266)(a, state.b);
else state.a = a;
}
}
@@ -935,16 +938,16 @@ function init(module) {
const ret = real;
return addHeapObject(ret);
};
- imports.wbg.__wbindgen_closure_wrapper523 = function(arg0, arg1, arg2) {
+ imports.wbg.__wbindgen_closure_wrapper228 = function(arg0, arg1, arg2) {
const state = { a: arg0, b: arg1, cnt: 1 };
- const real = () => {
+ const real = (arg0) => {
state.cnt++;
const a = state.a;
state.a = 0;
try {
- return __wbg_elem_binding4(a, state.b, );
+ return __wbg_elem_binding0(a, state.b, arg0);
} finally {
- if (--state.cnt === 0) wasm.__wbg_function_table.get(189)(a, state.b);
+ if (--state.cnt === 0) wasm.__wbg_function_table.get(42)(a, state.b);
else state.a = a;
}
}
@@ -953,16 +956,16 @@ function init(module) {
const ret = real;
return addHeapObject(ret);
};
- imports.wbg.__wbindgen_closure_wrapper217 = function(arg0, arg1, arg2) {
+ imports.wbg.__wbindgen_closure_wrapper236 = function(arg0, arg1, arg2) {
const state = { a: arg0, b: arg1, cnt: 1 };
const real = (arg0) => {
state.cnt++;
const a = state.a;
state.a = 0;
try {
- return __wbg_elem_binding0(a, state.b, arg0);
+ return __wbg_elem_binding5(a, state.b, arg0);
} finally {
- if (--state.cnt === 0) wasm.__wbg_function_table.get(43)(a, state.b);
+ if (--state.cnt === 0) wasm.__wbg_function_table.get(42)(a, state.b);
else state.a = a;
}
}
@@ -971,7 +974,7 @@ function init(module) {
const ret = real;
return addHeapObject(ret);
};
- imports.wbg.__wbindgen_closure_wrapper215 = function(arg0, arg1, arg2) {
+ imports.wbg.__wbindgen_closure_wrapper230 = function(arg0, arg1, arg2) {
const state = { a: arg0, b: arg1, cnt: 1 };
const real = (arg0) => {
state.cnt++;
@@ -980,7 +983,7 @@ function init(module) {
try {
return __wbg_elem_binding1(a, state.b, arg0);
} finally {
- if (--state.cnt === 0) wasm.__wbg_function_table.get(43)(a, state.b);
+ if (--state.cnt === 0) wasm.__wbg_function_table.get(42)(a, state.b);
else state.a = a;
}
}
@@ -989,16 +992,16 @@ function init(module) {
const ret = real;
return addHeapObject(ret);
};
- imports.wbg.__wbindgen_closure_wrapper219 = function(arg0, arg1, arg2) {
+ imports.wbg.__wbindgen_closure_wrapper234 = function(arg0, arg1, arg2) {
const state = { a: arg0, b: arg1, cnt: 1 };
const real = (arg0) => {
state.cnt++;
const a = state.a;
state.a = 0;
try {
- return __wbg_elem_binding2(a, state.b, arg0);
+ return __wbg_elem_binding6(a, state.b, arg0);
} finally {
- if (--state.cnt === 0) wasm.__wbg_function_table.get(43)(a, state.b);
+ if (--state.cnt === 0) wasm.__wbg_function_table.get(42)(a, state.b);
else state.a = a;
}
}
diff --git a/teleterm/static/teleterm_web_bg.wasm b/teleterm/static/teleterm_web_bg.wasm
index 291c9cc..320e714 100644
--- a/teleterm/static/teleterm_web_bg.wasm
+++ b/teleterm/static/teleterm_web_bg.wasm
Binary files differ