async fn handle_messages_from_game_thread(
    ws_send: app_socket::SendMessages,
    game_send: game_state::SendMessages,
) {
    use crate::app_messages::WindowMove;

    let (send, mut recv) = tokio::sync::mpsc::unbounded_channel();
    *crate::game_thread::SEND_FROM_GAME_THREAD.lock().unwrap() = Some(send);
    while let Some(message) = recv.recv().await {
        match message {
            GameThreadMessage::WindowMove(x, y, w, h) => {
                let msg = app_socket::encode_message("/game/windowMove", WindowMove { x, y, w, h });
                if let Some(msg) = msg {
                    let _ = ws_send.send(msg).await;
                }
            }
            other => {
                let _ = game_send.send(GameStateMessage::GameThread(other)).await;
            }
        }
    }
    // This should never be reached, this task should get combined to a future
    // which eventually is cancelled (by game state task) to stop everything.
    debug!("Stopping `game thread -> async` task");
}
/// Task that registers itself to receive messages from game thread and forwards them
/// to the arguments given to function.
Task that registers itself to receive messages from game thread and forwards them
to the arguments given to function.
Task that registers itself to receive messages from game thread and forwards them to the arguments given to function .
async fn handle_messages_from_game_thread(
    ws_send: app_socket::SendMessages,
    game_send: game_state::SendMessages,
) {
    use crate::app_messages::WindowMove;
    let (send, mut recv) = tokio::sync::mpsc::unbounded_channel();
    *crate::game_thread::SEND_FROM_GAME_THREAD.lock().unwrap() = Some(send);
    while let Some(message) = recv.recv().await {
        match message {
            GameThreadMessage::WindowMove(x, y, w, h) => {
                let msg = app_socket::encode_message("/game/windowMove", WindowMove { x, y, w, h });
                if let Some(msg) = msg {
                    let _ = ws_send.send(msg).await;
                }
            }
            other => {
                let _ = game_send.send(GameStateMessage::GameThread(other)).await;
            }
        }
    }
    // This should never be reached, this task should get combined to a future
    // which eventually is cancelled (by game state task) to stop everything.
    debug!("Stopping `game thread -> async` task");
}
async fn handle_messages_from_game_thread ( ws_send : app_socket :: SendMessages , game_send : game_state :: SendMessages , ) { use crate :: app_messages :: WindowMove ; let ( send , mut recv ) = tokio :: sync :: mpsc :: unbounded_channel ( ) ; * crate :: game_thread :: SEND_FROM_GAME_THREAD . lock ( ) . unwrap ( ) = Some ( send ) ; while let Some ( message ) = recv . recv ( ) . await { match message { GameThreadMessage :: WindowMove ( x , y , w , h ) => { let msg = app_socket :: encode_message ( " " , WindowMove { x , y , w , h } ) ; if let Some ( msg ) = msg { let _ = ws_send . send ( msg ) . await ; } } other => { let _ = game_send . send ( GameStateMessage :: GameThread ( other ) ) . await ; } } } // This should never be reached, this task should get combined to a future // which eventually is cancelled (by game state task) to stop everything. debug ! ( " " ) ; }
Task that registers itself to receive messages from game thread and forwards them
to the arguments given to function.
Task that registers itself to receive messages from game thread and forwards them to the arguments given to function .
ws_send
app_socket::SendMessages
game_send
game_state::SendMessages
ws_send
app_socket::SendMessages
game_send
game_state::SendMessages