mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 17:55:36 +00:00
aquatic_udp: move ConnectionKey and ConnectionMap to network.rs
This commit is contained in:
parent
de85feec9a
commit
e2be31c7de
2 changed files with 19 additions and 18 deletions
|
|
@ -1,5 +1,5 @@
|
|||
use std::hash::Hash;
|
||||
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr};
|
||||
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
|
||||
use std::sync::{atomic::AtomicUsize, Arc};
|
||||
use std::time::Instant;
|
||||
|
||||
|
|
@ -49,23 +49,6 @@ impl Into<Response> for ConnectedResponse {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct ConnectionKey {
|
||||
pub connection_id: ConnectionId,
|
||||
pub socket_addr: SocketAddr,
|
||||
}
|
||||
|
||||
impl ConnectionKey {
|
||||
pub fn new(connection_id: ConnectionId, socket_addr: SocketAddr) -> Self {
|
||||
Self {
|
||||
connection_id,
|
||||
socket_addr,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub type ConnectionMap = HashMap<ConnectionKey, ValidUntil>;
|
||||
|
||||
#[derive(PartialEq, Eq, Hash, Clone, Copy, Debug)]
|
||||
pub enum PeerStatus {
|
||||
Seeding,
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ use std::time::{Duration, Instant};
|
|||
use std::vec::Drain;
|
||||
|
||||
use crossbeam_channel::{Receiver, Sender};
|
||||
use hashbrown::HashMap;
|
||||
use mio::net::UdpSocket;
|
||||
use mio::{Events, Interest, Poll, Token};
|
||||
use rand::prelude::{Rng, SeedableRng, StdRng};
|
||||
|
|
@ -18,6 +19,23 @@ use aquatic_udp_protocol::{IpVersion, Request, Response};
|
|||
use crate::common::*;
|
||||
use crate::config::Config;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct ConnectionKey {
|
||||
pub connection_id: ConnectionId,
|
||||
pub socket_addr: SocketAddr,
|
||||
}
|
||||
|
||||
impl ConnectionKey {
|
||||
pub fn new(connection_id: ConnectionId, socket_addr: SocketAddr) -> Self {
|
||||
Self {
|
||||
connection_id,
|
||||
socket_addr,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub type ConnectionMap = HashMap<ConnectionKey, ValidUntil>;
|
||||
|
||||
pub fn run_socket_worker(
|
||||
state: State,
|
||||
config: Config,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue