From e0170f9dfcde4e279d78d9e4554cb4592e577612 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sat, 8 Apr 2023 21:09:49 -0400 Subject: [PATCH] *make message encoding/decoding async for use with the kernel --- index.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index f14aa85..d4c5ba0 100644 --- a/index.js +++ b/index.js @@ -223,34 +223,34 @@ class Channel { type, encoding, onmessage, - recv(state, session) { - session._track(m.onmessage(encoding.decode(state), session)); + async recv(state, session) { + session._track(m.onmessage(await encoding.decode(state), session)); }, - send(m, session = s) { + async send(m, session = s) { if (session.closed === true) return false; const mux = session._mux; const state = { buffer: null, start: 0, end: typeLen }; if (mux._batch !== null) { - encoding.preencode(state, m); + await encoding.preencode(state, m); state.buffer = mux._alloc(state.end); c.uint.encode(state, type); - encoding.encode(state, m); + await encoding.encode(state, m); mux._pushBatch(session._localId, state.buffer); return true; } c.uint.preencode(state, session._localId); - encoding.preencode(state, m); + await encoding.preencode(state, m); state.buffer = mux._alloc(state.end); c.uint.encode(state, session._localId); c.uint.encode(state, type); - encoding.encode(state, m); + await encoding.encode(state, m); return mux.stream.write(state.buffer); },