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