mirror of
https://github.com/MercuryWorkshop/epoxy-tls.git
synced 2025-05-13 06:20:02 -04:00
update server,client,simple-wisp-client for new api
This commit is contained in:
parent
481128e4f5
commit
b8eb13903b
3 changed files with 9 additions and 34 deletions
|
@ -7,10 +7,7 @@ use wasm_bindgen_futures::JsFuture;
|
|||
use hyper::rt::Executor;
|
||||
use js_sys::ArrayBuffer;
|
||||
use std::future::Future;
|
||||
use wisp_mux::{
|
||||
extensions::udp::{UdpProtocolExtension, UdpProtocolExtensionBuilder},
|
||||
WispError,
|
||||
};
|
||||
use wisp_mux::{extensions::udp::UdpProtocolExtensionBuilder, WispError};
|
||||
|
||||
#[wasm_bindgen]
|
||||
extern "C" {
|
||||
|
@ -207,13 +204,7 @@ pub async fn make_mux(
|
|||
.await
|
||||
.map_err(|_| WispError::WsImplSocketClosed)?;
|
||||
wtx.wait_for_open().await;
|
||||
let mux = ClientMux::new(
|
||||
wrx,
|
||||
wtx,
|
||||
Some(vec![UdpProtocolExtension().into()]),
|
||||
Some(&[&UdpProtocolExtensionBuilder()]),
|
||||
)
|
||||
.await?;
|
||||
let mux = ClientMux::new(wrx, wtx, Some(&[&UdpProtocolExtensionBuilder()])).await?;
|
||||
|
||||
Ok(mux)
|
||||
}
|
||||
|
|
|
@ -20,8 +20,8 @@ use tokio_util::codec::{BytesCodec, Framed};
|
|||
use tokio_util::either::Either;
|
||||
|
||||
use wisp_mux::{
|
||||
extensions::udp::{UdpProtocolExtension, UdpProtocolExtensionBuilder},
|
||||
CloseReason, ConnectPacket, MuxStream, ServerMux, StreamType, WispError,
|
||||
extensions::udp::UdpProtocolExtensionBuilder, CloseReason, ConnectPacket, MuxStream, ServerMux,
|
||||
StreamType, WispError,
|
||||
};
|
||||
|
||||
type HttpBody = http_body_util::Full<hyper::body::Bytes>;
|
||||
|
@ -263,14 +263,8 @@ async fn accept_ws(
|
|||
|
||||
println!("{:?}: connected", addr);
|
||||
|
||||
let (mut mux, fut) = ServerMux::new(
|
||||
rx,
|
||||
tx,
|
||||
u32::MAX,
|
||||
Some(vec![UdpProtocolExtension().into()]),
|
||||
Some(&[&UdpProtocolExtensionBuilder()]),
|
||||
)
|
||||
.await?;
|
||||
let (mut mux, fut) =
|
||||
ServerMux::new(rx, tx, u32::MAX, Some(&[&UdpProtocolExtensionBuilder()])).await?;
|
||||
|
||||
tokio::spawn(async move {
|
||||
if let Err(e) = fut.await {
|
||||
|
|
|
@ -18,7 +18,6 @@ use std::{
|
|||
process::exit,
|
||||
sync::Arc,
|
||||
time::{Duration, Instant},
|
||||
usize,
|
||||
};
|
||||
use tokio::{
|
||||
net::TcpStream,
|
||||
|
@ -28,10 +27,7 @@ use tokio::{
|
|||
};
|
||||
use tokio_native_tls::{native_tls, TlsConnector};
|
||||
use tokio_util::either::Either;
|
||||
use wisp_mux::{
|
||||
extensions::udp::{UdpProtocolExtension, UdpProtocolExtensionBuilder},
|
||||
ClientMux, StreamType, WispError,
|
||||
};
|
||||
use wisp_mux::{extensions::udp::UdpProtocolExtensionBuilder, ClientMux, StreamType, WispError};
|
||||
|
||||
#[derive(Debug)]
|
||||
enum WispClientError {
|
||||
|
@ -138,15 +134,9 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
|
|||
let rx = FragmentCollectorRead::new(rx);
|
||||
|
||||
let (mut mux, fut) = if opts.udp {
|
||||
ClientMux::new(
|
||||
rx,
|
||||
tx,
|
||||
Some(vec![UdpProtocolExtension().into()]),
|
||||
Some(&[&UdpProtocolExtensionBuilder()]),
|
||||
)
|
||||
.await?
|
||||
ClientMux::new(rx, tx, Some(&[&UdpProtocolExtensionBuilder()])).await?
|
||||
} else {
|
||||
ClientMux::new(rx, tx, Some(vec![]), Some(&[])).await?
|
||||
ClientMux::new(rx, tx, Some(&[])).await?
|
||||
};
|
||||
|
||||
let mut threads = Vec::with_capacity(opts.streams * 2 + 3);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue