-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial barebones for browser wasm support
- Loading branch information
Showing
3 changed files
with
61 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
use crate::{stream::MaybeTlsStream, Connector, WebSocketStream}; | ||
|
||
use tungstenite::{ | ||
error::{Error, UrlError}, | ||
handshake::client::{Request, Response}, | ||
protocol::WebSocketConfig, | ||
//client::IntoClientRequest, | ||
}; | ||
//use web_sys::WebSocket; | ||
use ws_stream_wasm::WsStreamIo; | ||
use async_io_stream::IoStream; | ||
|
||
|
||
|
||
pub async fn connect( | ||
request: Request, | ||
config: Option<WebSocketConfig>, | ||
disable_nagle: bool, | ||
//connector: Option<Connector>, | ||
) -> Result<(WebSocketStream<MaybeTlsStream<IoStream<WsStreamIo, Vec<u8>>>>, Response), Error> { | ||
//let domain = domain(&request)?; | ||
let domain = request.uri().host().unwrap(); | ||
let port = request | ||
.uri() | ||
.port_u16() | ||
.or_else(|| match request.uri().scheme_str() { | ||
Some("wss") => Some(443), | ||
Some("ws") => Some(80), | ||
_ => None, | ||
}) | ||
.ok_or(Error::Url(UrlError::UnsupportedUrlScheme))?; | ||
|
||
let addr = format!("{domain}:{port}"); | ||
//let socket = TcpStream::connect(addr).await.map_err(Error::Io)?; | ||
|
||
if disable_nagle { | ||
//socket.set_nodelay(true)?; | ||
} | ||
todo!(); | ||
|
||
//crate::tls::client_async_tls_with_config(request, socket, config, connector).await | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters