parent
089def45d1
commit
203ef1adcc
10 changed files with 55 additions and 76 deletions
|
|
@ -58,7 +58,10 @@ impl WasmPipeHandle {
|
|||
|
||||
match accepted {
|
||||
Ok(true) => {
|
||||
let writer = self.transport.open_pipe(self.pipe_id, &self.description).await?;
|
||||
let writer = self
|
||||
.transport
|
||||
.open_pipe(self.pipe_id, &self.description)
|
||||
.await?;
|
||||
Ok(JsValue::from(writer))
|
||||
}
|
||||
Ok(false) => Ok(JsValue::NULL),
|
||||
|
|
@ -783,12 +786,11 @@ impl WasmClient {
|
|||
|
||||
let pipe_id = random_pipe_id()?;
|
||||
let (tx, rx) = oneshot::channel();
|
||||
self.pending_pipe_creations
|
||||
.borrow_mut()
|
||||
.insert(pipe_id, tx);
|
||||
self.pending_pipe_creations.borrow_mut().insert(pipe_id, tx);
|
||||
|
||||
let request =
|
||||
CommunicationValue::new(CommunicationType::PipeRequest).with_id(pipe_id).add_typed_default(
|
||||
let request = CommunicationValue::new(CommunicationType::PipeRequest)
|
||||
.with_id(pipe_id)
|
||||
.add_typed_default(
|
||||
DataType::Description,
|
||||
DataValue::Str(description.to_string()),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::JsCast;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen_futures::JsFuture;
|
||||
|
||||
use crate::error::js_error;
|
||||
|
|
@ -56,9 +56,7 @@ impl PipeWriter {
|
|||
let close_promise = close_fn
|
||||
.call0(&self.writer)
|
||||
.map_err(|e| js_error(&format!("close failed: {:?}", e)))?;
|
||||
if let Err(e) =
|
||||
JsFuture::from(close_promise.unchecked_into::<js_sys::Promise>()).await
|
||||
{
|
||||
if let Err(e) = JsFuture::from(close_promise.unchecked_into::<js_sys::Promise>()).await {
|
||||
crate::transport::log_stream_error_code(&e, "pipe writer close");
|
||||
}
|
||||
release_writer_lock(&self.writer);
|
||||
|
|
|
|||
|
|
@ -467,8 +467,8 @@ impl WasmTransport {
|
|||
F: FnMut(JsValue),
|
||||
G: FnMut(crate::pipe::PipeReader),
|
||||
{
|
||||
let pipe_request_type = mtp_codec::CommunicationType::PipeRequest
|
||||
.to_id(&mtp_codec::TypeMap::latest());
|
||||
let pipe_request_type =
|
||||
mtp_codec::CommunicationType::PipeRequest.to_id(&mtp_codec::TypeMap::latest());
|
||||
|
||||
loop {
|
||||
match self.next_frame().await {
|
||||
|
|
@ -509,8 +509,7 @@ impl WasmTransport {
|
|||
}
|
||||
Err(e) => {
|
||||
let message = e.as_string().unwrap_or_else(|| format!("{:?}", e));
|
||||
let _ =
|
||||
on_error.call1(&JsValue::NULL, &JsValue::from_str(&message));
|
||||
let _ = on_error.call1(&JsValue::NULL, &JsValue::from_str(&message));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -574,9 +573,7 @@ impl WasmTransport {
|
|||
let write_promise = write_fn
|
||||
.call1(&writer_val, &chunk)
|
||||
.map_err(|e| js_error(&format!("write failed: {:?}", e)))?;
|
||||
if let Err(e) =
|
||||
JsFuture::from(write_promise.unchecked_into::<js_sys::Promise>()).await
|
||||
{
|
||||
if let Err(e) = JsFuture::from(write_promise.unchecked_into::<js_sys::Promise>()).await {
|
||||
log_stream_error_code(&e, "open_pipe write");
|
||||
release_writer_lock(&writer_val);
|
||||
return Err(e);
|
||||
|
|
|
|||
Loading…
Reference in a new issue