clean up a bit

This commit is contained in:
Maple Nebel 2025-11-08 13:00:23 +00:00
commit 6ea1518a9d
5 changed files with 65 additions and 97 deletions

View file

@ -1,26 +1,16 @@
use std::io::Cursor;
use rnex_core::rmc::structures::RmcSerialize;
use rnex_core::reggie::UnitPacketRead;
use std::net::SocketAddrV4;
use std::sync::Arc;
use std::sync::atomic::AtomicU32;
use log::{error, info};
use tokio::net::TcpListener;
use tokio::task;
use rnex_core::common::setup;
use rnex_core::executables::common::{OWN_IP_PRIVATE, SERVER_PORT};
use rnex_core::executables::common::{new_simple_backend};
use rnex_core::nex::matchmake::MatchmakeManager;
use rnex_core::nex::remote_console::RemoteConsole;
use rnex_core::nex::user::User;
use rnex_core::rmc::protocols::new_rmc_gateway_connection;
use rnex_core::rnex_proxy_common::ConnectionInitData;
use rnex_core::rmc::protocols::RemoteInstantiatable;
#[tokio::main]
async fn main() {
setup();
let listen = TcpListener::bind(SocketAddrV4::new(*OWN_IP_PRIVATE, *SERVER_PORT)).await.unwrap();
let mmm = Arc::new(MatchmakeManager{
gid_counter: AtomicU32::new(1),
@ -33,40 +23,15 @@ async fn main() {
MatchmakeManager::initialize_garbage_collect_thread(weak_mmm).await;
while let Ok((mut stream, _addr)) = listen.accept().await {
let buffer = match stream.read_buffer().await{
Ok(v) => v,
Err(e) => {
error!("an error ocurred whilest reading connection data buffer: {:?}", e);
continue;
}
};
let user_connection_data = ConnectionInitData::deserialize(&mut Cursor::new(buffer));
let user_connection_data = match user_connection_data{
Ok(v) => v,
Err(e) => {
error!("an error ocurred whilest reading connection data: {:?}", e);
continue;
}
};
new_simple_backend(move |c, r|{
let mmm = mmm.clone();
task::spawn(async move {
info!("connection to secure backend established");
new_rmc_gateway_connection(stream.into(), |r| {
Arc::new_cyclic(|this| User{
this: this.clone(),
ip: user_connection_data.prudpsock_addr,
pid: user_connection_data.pid,
remote: RemoteConsole::new(r),
matchmake_manager: mmm,
station_url: Default::default()
})
});
});
}
Arc::new_cyclic(move |this| User{
this: this.clone(),
ip: c.prudpsock_addr,
pid:c.pid,
remote: RemoteConsole::new(r),
matchmake_manager: mmm,
station_url: Default::default()
})
}).await;
}