stuff
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
use crate::ClientEvent;
|
||||
use dashmap::DashMap;
|
||||
use openworm::net::{
|
||||
ClientMsg, ClientRequestMsg, CreateAccount, CreateAccountResp, Login, LoginResp, RecvHandler,
|
||||
RequestId, SERVER_NAME, ServerMsg, ServerRespMsg, SkipServerVerification, recv_uni, send_uni,
|
||||
ClientMsg, ClientRequestMsg, RecvHandler, RequestId, RequestMsg, SERVER_NAME, ServerMsg,
|
||||
ServerRespMsg, SkipServerVerification, recv_uni, send_uni,
|
||||
};
|
||||
use quinn::{
|
||||
ClientConfig, Connection, Endpoint, IdleTimeout, TransportConfig,
|
||||
@@ -25,6 +25,7 @@ pub struct ConnectInfo {
|
||||
pub cert: Vec<u8>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct NetHandle {
|
||||
send: UnboundedSender<NetCtrlMsg>,
|
||||
}
|
||||
@@ -75,35 +76,6 @@ impl NetHandle {
|
||||
}
|
||||
}
|
||||
|
||||
pub trait RequestMsg: Into<ClientMsg> {
|
||||
type Result;
|
||||
fn result(msg: ServerMsg) -> Option<Self::Result>;
|
||||
}
|
||||
|
||||
impl RequestMsg for CreateAccount {
|
||||
type Result = CreateAccountResp;
|
||||
|
||||
fn result(msg: ServerMsg) -> Option<Self::Result> {
|
||||
if let ServerMsg::CreateAccountResp(res) = msg {
|
||||
Some(res)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl RequestMsg for Login {
|
||||
type Result = LoginResp;
|
||||
|
||||
fn result(msg: ServerMsg) -> Option<Self::Result> {
|
||||
if let ServerMsg::LoginResp(res) = msg {
|
||||
Some(res)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async fn connection_cert(
|
||||
addr: SocketAddr,
|
||||
cert: CertificateDer<'_>,
|
||||
@@ -118,8 +90,7 @@ async fn connection_cert(
|
||||
let client_config = ClientConfig::new(Arc::new(
|
||||
QuicClientConfig::try_from(client_crypto).map_err(|e| e.to_string())?,
|
||||
));
|
||||
let mut endpoint = quinn::Endpoint::client(SocketAddr::from_str("[::]:0").unwrap())
|
||||
.map_err(|e| e.to_string())?;
|
||||
let mut endpoint = quinn::Endpoint::client(CLIENT_SOCKET).map_err(|e| e.to_string())?;
|
||||
endpoint.set_default_client_config(client_config);
|
||||
let conn = endpoint
|
||||
.connect(addr, SERVER_NAME)
|
||||
|
||||
Reference in New Issue
Block a user