wasm cleanup

This commit is contained in:
John Smith
2022-07-12 08:02:22 -04:00
parent b73511142a
commit b9acd532db
19 changed files with 248 additions and 335 deletions

View File

@@ -333,6 +333,7 @@ impl ConnectionManager {
// Called by low-level network when any connection-oriented protocol connection appears
// either from incoming connections.
#[cfg_attr(target_os = "wasm32", allow(dead_code))]
pub(super) async fn on_accepted_protocol_network_connection(
&self,
conn: ProtocolNetworkConnection,

View File

@@ -7,6 +7,7 @@ use std::io;
#[derive(Debug)]
pub enum ProtocolNetworkConnection {
#[allow(dead_code)]
Dummy(DummyNetworkConnection),
Ws(ws::WebsocketNetworkConnection),
//WebRTC(wrtc::WebRTCNetworkConnection),

View File

@@ -2,9 +2,10 @@ use super::*;
use futures_util::{SinkExt, StreamExt};
use std::io;
use ws_stream_wasm::*;
use send_wrapper::*;
struct WebsocketNetworkConnectionInner {
ws_meta: WsMeta,
_ws_meta: WsMeta,
ws_stream: CloneStream<WsStream>,
}
@@ -29,7 +30,7 @@ impl WebsocketNetworkConnection {
Self {
descriptor,
inner: Arc::new(WebsocketNetworkConnectionInner {
ws_meta,
_ws_meta: ws_meta,
ws_stream: CloneStream::new(ws_stream),
}),
}
@@ -59,7 +60,7 @@ impl WebsocketNetworkConnection {
#[instrument(level = "trace", err, skip(self), fields(ret.len))]
pub async fn recv(&self) -> io::Result<Vec<u8>> {
let out = match self.inner.ws_stream.clone().next().await {
let out = match SendWrapper::new(self.inner.ws_stream.clone().next()).await {
Some(WsMessage::Binary(v)) => v,
Some(x) => {
bail_io_error_other!("Unexpected WS message type");
@@ -100,7 +101,8 @@ impl WebsocketProtocolHandler {
bail_io_error_other!("invalid websocket url scheme");
}
let (wsmeta, wsio) = WsMeta::connect(request, None).await.map_err(to_io)?;
let fut = spawn_local(WsMeta::connect(request, None));
let (wsmeta, wsio) = fut.await.map_err(to_io)?;
// Make our connection descriptor
Ok(ProtocolNetworkConnection::Ws(