/// Read messages from the 'server output channel' and push them onto the WebSockets server ref.
Read messages from the 'server output channel' and push them onto the WebSockets server ref.
Read messages from the ' server output channel ' and push them onto the WebSockets server ref .
async fn forward_messages<ServerMessage>(
    mut output_receiver: Receiver<ServerMessage>,
    server_handle: ServerRef,
) where
    ServerMessage: Serialize + Clone,
{
    loop {
        let message = output_receiver.recv().await.unwrap();
        let message = serde_json::to_string(&message);
        match message {
            Ok(message) => {
                let handle = server_handle.lock().await;
                handle.send(message).await;
            }
            Err(err) => {
                log::error!("Failed to serialize message {}", err)
            }
        }
    }
}
async fn forward_messages < ServerMessage > ( mut output_receiver : Receiver < ServerMessage > , server_handle : ServerRef , ) where ServerMessage : Serialize + Clone , { loop { let message = output_receiver . recv ( ) . await . unwrap ( ) ; let message = serde_json :: to_string ( & message ) ; match message { Ok ( message ) => { let handle = server_handle . lock ( ) . await ; handle . send ( message ) . await ; } Err ( err ) => { log :: error ! ( " " err ) } } } }
Read messages from the 'server output channel' and push them onto the WebSockets server ref.
Read messages from the ' server output channel ' and push them onto the WebSockets server ref .
output_receiver
Receiver<ServerMessage>
server_handle
ServerRef