Some checks failed
Build and Test / super-mario-maker (push) Failing after 10m30s
Build and Test / fast-racing-neo (push) Failing after 11m40s
Build and Test / friends (push) Failing after 11m56s
Build and Test / wii-sports-club (push) Failing after 12m9s
Build and Test / splatoon (push) Failing after 12m14s
Build and Test / puyopuyo (push) Failing after 12m23s
Build and Test / wii-u-chat (push) Failing after 12m23s
Build and Test / mario-tennis (push) Failing after 12m23s
Build and Test / sonic-transformed (push) Failing after 12m23s
Build and Test / splatoon-testfire (push) Failing after 12m30s
Build and Test / minecraft-wiiu (push) Failing after 12m37s
73 lines
2.2 KiB
Rust
73 lines
2.2 KiB
Rust
use std::{
|
|
io::Cursor,
|
|
net::SocketAddrV4,
|
|
sync::{Arc, atomic::AtomicU32},
|
|
};
|
|
|
|
use tokio::net::TcpListener;
|
|
use tracing::error;
|
|
|
|
use crate::{
|
|
executables::common::{OWN_IP_PRIVATE, SERVER_PORT},
|
|
nex::friends_handler::{FriendsGuest, FriendsManager, FriendsUser, RemoteFriendRemote},
|
|
reggie::UnitPacketRead,
|
|
rmc::{
|
|
protocols::{RmcPureRemoteObject, new_rmc_gateway_connection},
|
|
structures::RmcSerialize,
|
|
},
|
|
rnex_proxy_common::ConnectionInitData,
|
|
};
|
|
|
|
pub async fn start_friends_backend() {
|
|
let fm = Arc::new(FriendsManager {
|
|
cid_counter: AtomicU32::new(1),
|
|
users: Default::default(),
|
|
});
|
|
let listen = TcpListener::bind(SocketAddrV4::new(*OWN_IP_PRIVATE, *SERVER_PORT))
|
|
.await
|
|
.unwrap();
|
|
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 whilst reading connection data buffer: {:?}",
|
|
e
|
|
);
|
|
continue;
|
|
}
|
|
};
|
|
|
|
let user_connection_data = ConnectionInitData::deserialize(&mut Cursor::new(buffer));
|
|
|
|
let c = match user_connection_data {
|
|
Ok(v) => v,
|
|
Err(e) => {
|
|
error!("an error ocurred whilst reading connection data: {:?}", e);
|
|
continue;
|
|
}
|
|
};
|
|
let fm = fm.clone();
|
|
if c.pid != 100 {
|
|
new_rmc_gateway_connection(stream.into(), move |r| {
|
|
Arc::new_cyclic(move |this| FriendsUser {
|
|
fm,
|
|
addr: c.prudpsock_addr,
|
|
pid: c.pid,
|
|
this: this.clone(),
|
|
remote: RemoteFriendRemote::new(r),
|
|
friend_pids: Default::default(),
|
|
maybe_remote_friend: Default::default(),
|
|
presence: Default::default(),
|
|
})
|
|
});
|
|
} else {
|
|
new_rmc_gateway_connection(stream.into(), move |_| {
|
|
Arc::new_cyclic(move |_| FriendsGuest {
|
|
fm,
|
|
addr: c.prudpsock_addr,
|
|
})
|
|
});
|
|
}
|
|
}
|
|
}
|