|
@ -79,7 +79,7 @@ where |
|
|
ships.insert(server_id, ship_action_sender);
|
|
|
ships.insert(server_id, ship_action_sender);
|
|
|
for (server, action) in state.on_connect(server_id).await {
|
|
|
for (server, action) in state.on_connect(server_id).await {
|
|
|
if let Some(sender) = ships.get_mut(&server) {
|
|
|
if let Some(sender) = ships.get_mut(&server) {
|
|
|
sender.send(action).await;
|
|
|
|
|
|
|
|
|
sender.send(action).await.unwrap();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
},
|
|
@ -89,7 +89,7 @@ where |
|
|
Ok(actions) => {
|
|
|
Ok(actions) => {
|
|
|
for (server, action) in actions{
|
|
|
for (server, action) in actions{
|
|
|
if let Some(sender) = ships.get_mut(&server) {
|
|
|
if let Some(sender) = ships.get_mut(&server) {
|
|
|
sender.send(action).await;
|
|
|
|
|
|
|
|
|
sender.send(action).await.unwrap();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
},
|
|
@ -103,7 +103,7 @@ where |
|
|
ships.remove(&server_id);
|
|
|
ships.remove(&server_id);
|
|
|
for (server, action) in actions {
|
|
|
for (server, action) in actions {
|
|
|
if let Some(sender) = ships.get_mut(&server) {
|
|
|
if let Some(sender) = ships.get_mut(&server) {
|
|
|
sender.send(action).await;
|
|
|
|
|
|
|
|
|
sender.send(action).await.unwrap();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@ -121,7 +121,7 @@ where |
|
|
R: DeserializeOwned + std::fmt::Debug + Send + 'static,
|
|
|
R: DeserializeOwned + std::fmt::Debug + Send + 'static,
|
|
|
{
|
|
|
{
|
|
|
async_std::task::spawn(async move {
|
|
|
async_std::task::spawn(async move {
|
|
|
state_loop_sender.send(InterserverInputAction::NewConnection(server_id, output_loop_sender)).await;
|
|
|
|
|
|
|
|
|
state_loop_sender.send(InterserverInputAction::NewConnection(server_id, output_loop_sender)).await.unwrap();
|
|
|
let mut msg_receiver = MessageReceiver::new(socket);
|
|
|
let mut msg_receiver = MessageReceiver::new(socket);
|
|
|
|
|
|
|
|
|
loop {
|
|
|
loop {
|
|
@ -129,12 +129,12 @@ where |
|
|
match msg_receiver.recv().await {
|
|
|
match msg_receiver.recv().await {
|
|
|
Ok(msg) => {
|
|
|
Ok(msg) => {
|
|
|
info!("[login recv loop msg] {:?}", msg);
|
|
|
info!("[login recv loop msg] {:?}", msg);
|
|
|
state_loop_sender.send(InterserverInputAction::Message(server_id, msg)).await;
|
|
|
|
|
|
|
|
|
state_loop_sender.send(InterserverInputAction::Message(server_id, msg)).await.unwrap();
|
|
|
},
|
|
|
},
|
|
|
Err(err) => {
|
|
|
Err(err) => {
|
|
|
if let MessageReceiverError::Disconnected = err {
|
|
|
if let MessageReceiverError::Disconnected = err {
|
|
|
info!("[login recv loop disconnect] {:?}", server_id);
|
|
|
info!("[login recv loop disconnect] {:?}", server_id);
|
|
|
state_loop_sender.send(InterserverInputAction::Disconnect(server_id)).await;
|
|
|
|
|
|
|
|
|
state_loop_sender.send(InterserverInputAction::Disconnect(server_id)).await.unwrap();
|
|
|
break;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
info!("[login recv loop err] {:?}", err);
|
|
|
info!("[login recv loop err] {:?}", err);
|
|
@ -200,7 +200,7 @@ pub fn login_listen_mainloop<EG: EntityGateway + 'static>(state: Arc<Mutex<Chara |
|
|
let mut state = state.lock().await;
|
|
|
let mut state = state.lock().await;
|
|
|
let local_sender = client_sender.clone();
|
|
|
let local_sender = client_sender.clone();
|
|
|
state.set_sender(server_id, Box::new(move |message| {
|
|
|
state.set_sender(server_id, Box::new(move |message| {
|
|
|
async_std::task::block_on(local_sender.send(message));
|
|
|
|
|
|
|
|
|
async_std::task::block_on(local_sender.send(message)).unwrap();
|
|
|
}))
|
|
|
}))
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
@ -236,7 +236,7 @@ pub fn ship_connect_mainloop<EG: EntityGateway + 'static>(state: Arc<Mutex<ShipS |
|
|
let mut state = state.lock().await;
|
|
|
let mut state = state.lock().await;
|
|
|
let local_sender = client_sender.clone();
|
|
|
let local_sender = client_sender.clone();
|
|
|
state.set_sender(Box::new(move |message| {
|
|
|
state.set_sender(Box::new(move |message| {
|
|
|
async_std::task::block_on(local_sender.send(message));
|
|
|
|
|
|
|
|
|
async_std::task::block_on(local_sender.send(message)).unwrap();
|
|
|
}))
|
|
|
}))
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|