fn handle_messages(
    mut new_messages: EventReader<NetworkData<shared::UserChatMessage>>,
    net: Res<NetworkServer>,
) {
    for message in new_messages.iter() {
        let user = message.source();

        info!("Received message from user: {}", message.message);

        net.broadcast(shared::NewChatMessage {
            name: format!("{}", user),
            message: message.message.clone(),
        });
    }
}
// Receiving a new message is as simple as listening for events of `NetworkData<T>`
Receiving a new message is as simple as listening for events of `NetworkData`
Receiving a new message is as simple as listening for events of ` NetworkData `
fn handle_messages(
    mut new_messages: EventReader<NetworkData<shared::UserChatMessage>>,
    net: Res<NetworkServer>,
) {
    for message in new_messages.iter() {
        let user = message.source();
        info!("Received message from user: {}", message.message);
        net.broadcast(shared::NewChatMessage {
            name: format!("{}", user),
            message: message.message.clone(),
        });
    }
}
fn handle_messages ( mut new_messages : EventReader < NetworkData < shared :: UserChatMessage > > , net : Res < NetworkServer > , ) { for message in new_messages . iter ( ) { let user = message . source ( ) ; info ! ( " " message message ) ; net . broadcast ( shared :: NewChatMessage { name : format ! ( " " user ) , message : message . message . clone ( ) , } ) ; } }
Receiving a new message is as simple as listening for events of `NetworkData<T>`
Receiving a new message is as simple as listening for events of ` NetworkData<T > `
new_messages
EventReader<NetworkData<shared::UserChatMessage>>
net
Res<NetworkServer>
new_messages
EventReader<NetworkData<shared::UserChatMessage>>
net
Res<NetworkServer>