引入客户端

This commit is contained in:
2025-02-23 16:36:45 +08:00
parent 232547b79e
commit 5c140d011f
6 changed files with 135 additions and 24 deletions

View File

@@ -7,7 +7,6 @@
use crate::close_sender::CloseSender;
use crate::packet::code::{SERVER_ACK, SERVER_ERROR};
use crate::packet::{read_packet, NetworkPackets};
use crate::server::accept::{OwnedReadHalfAbstraction, OwnedWriteHalfAbstraction, SocketAddr};
use crate::server::event::ServerEvent;
use crate::server::ClientID;
use crate::ssl::ServerCert;
@@ -20,6 +19,8 @@ use std::sync::{Arc, OnceLock};
use std::time::Duration;
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::sync::Mutex;
use crate::server::accept::SocketAddr;
use crate::stream::{OwnedReadHalfAbstraction, OwnedWriteHalfAbstraction};
pub type ReadSoc = Mutex<Option<Box<dyn OwnedReadHalfAbstraction>>>;
pub type WriteSoc = Mutex<Box<dyn OwnedWriteHalfAbstraction>>;

View File

@@ -6,28 +6,8 @@
use async_trait::async_trait;
use tokio::io;
use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt};
use tokio::net::{tcp, unix, TcpListener, UnixListener};
/// 读取抽象
#[async_trait]
pub trait OwnedReadHalfAbstraction: AsyncRead + Unpin + Send + Sync {}
/// 写入抽象
#[async_trait]
pub trait OwnedWriteHalfAbstraction: AsyncWrite + Unpin + Send + Sync {}
#[async_trait]
impl OwnedReadHalfAbstraction for tcp::OwnedReadHalf {}
#[async_trait]
impl OwnedReadHalfAbstraction for unix::OwnedReadHalf {}
#[async_trait]
impl OwnedWriteHalfAbstraction for tcp::OwnedWriteHalf {}
#[async_trait]
impl OwnedWriteHalfAbstraction for unix::OwnedWriteHalf {}
use crate::stream::{OwnedReadHalfAbstraction, OwnedWriteHalfAbstraction};
#[async_trait]
pub trait AcceptSocket: Send + Sync {