|
@ -186,7 +186,7 @@ pub fn login_listen_mainloop<EG: EntityGateway + 'static>(state: Arc<Mutex<Chara |
|
|
let mut id = 0;
|
|
|
let mut id = 0;
|
|
|
|
|
|
|
|
|
let (server_state_sender, server_state_receiver) = async_std::sync::channel(1024);
|
|
|
let (server_state_sender, server_state_receiver) = async_std::sync::channel(1024);
|
|
|
interserver_state_loop(state, server_state_receiver).await;
|
|
|
|
|
|
|
|
|
interserver_state_loop(state.clone(), server_state_receiver).await;
|
|
|
|
|
|
|
|
|
loop {
|
|
|
loop {
|
|
|
let (socket, addr) = listener.accept().await.unwrap();
|
|
|
let (socket, addr) = listener.accept().await.unwrap();
|
|
@ -194,9 +194,17 @@ pub fn login_listen_mainloop<EG: EntityGateway + 'static>(state: Arc<Mutex<Chara |
|
|
|
|
|
|
|
|
id += 1;
|
|
|
id += 1;
|
|
|
let server_id = crate::common::interserver::ServerId(id);
|
|
|
let server_id = crate::common::interserver::ServerId(id);
|
|
|
|
|
|
|
|
|
let (client_sender, client_receiver) = async_std::sync::channel(64);
|
|
|
let (client_sender, client_receiver) = async_std::sync::channel(64);
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
let mut state = state.lock().await;
|
|
|
|
|
|
let local_sender = client_sender.clone();
|
|
|
|
|
|
state.set_sender(server_id, Box::new(|message| {
|
|
|
|
|
|
async_std::task::block_on(local_sender.send(message));
|
|
|
|
|
|
}))
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
login_recv_loop(server_id, socket.clone(), server_state_sender.clone(), client_sender).await;
|
|
|
login_recv_loop(server_id, socket.clone(), server_state_sender.clone(), client_sender).await;
|
|
|
interserver_send_loop(server_id, socket.clone(), client_receiver).await;
|
|
|
interserver_send_loop(server_id, socket.clone(), client_receiver).await;
|
|
|
}
|
|
|
}
|
|
@ -206,9 +214,9 @@ pub fn login_listen_mainloop<EG: EntityGateway + 'static>(state: Arc<Mutex<Chara |
|
|
pub fn ship_connect_mainloop<EG: EntityGateway + 'static>(state: Arc<Mutex<ShipServerState<EG>>>, ip: std::net::Ipv4Addr, port: u16) -> Pin<Box<dyn Future<Output = ()>>> {
|
|
|
pub fn ship_connect_mainloop<EG: EntityGateway + 'static>(state: Arc<Mutex<ShipServerState<EG>>>, ip: std::net::Ipv4Addr, port: u16) -> Pin<Box<dyn Future<Output = ()>>> {
|
|
|
Box::pin(async_std::task::spawn(async move {
|
|
|
Box::pin(async_std::task::spawn(async move {
|
|
|
let mut id = 0;
|
|
|
let mut id = 0;
|
|
|
|
|
|
|
|
|
let (server_state_sender, server_state_receiver) = async_std::sync::channel(1024);
|
|
|
let (server_state_sender, server_state_receiver) = async_std::sync::channel(1024);
|
|
|
interserver_state_loop(state, server_state_receiver).await;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
interserver_state_loop(state.clone(), server_state_receiver).await;
|
|
|
|
|
|
|
|
|
loop {
|
|
|
loop {
|
|
|
info!("trying to connect to loginserv");
|
|
|
info!("trying to connect to loginserv");
|
|
@ -225,6 +233,14 @@ pub fn ship_connect_mainloop<EG: EntityGateway + 'static>(state: Arc<Mutex<ShipS |
|
|
info!("found loginserv: {:?} {:?}", server_id, socket);
|
|
|
info!("found loginserv: {:?} {:?}", server_id, socket);
|
|
|
let (client_sender, client_receiver) = async_std::sync::channel(64);
|
|
|
let (client_sender, client_receiver) = async_std::sync::channel(64);
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
let mut state = state.lock().await;
|
|
|
|
|
|
let local_sender = client_sender.clone();
|
|
|
|
|
|
state.set_sender(Box::new(move |message| {
|
|
|
|
|
|
async_std::task::block_on(local_sender.send(message));
|
|
|
|
|
|
}))
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
login_recv_loop(server_id, socket.clone(), server_state_sender.clone(), client_sender).await;
|
|
|
login_recv_loop(server_id, socket.clone(), server_state_sender.clone(), client_sender).await;
|
|
|
interserver_send_loop(server_id, socket.clone(), client_receiver).await;
|
|
|
interserver_send_loop(server_id, socket.clone(), client_receiver).await;
|
|
|
|
|
|
|
|
|