DEVELOPMENT ENVIRONMENT

~liljamo/deck-builder

f95462c1f78a1efe2a77aba31952a9b7887b5af3 — Jonni Liljamo 1 year, 10 months ago a036b2f
feat(shared): setup server protocol configuration
M shared/src/lib.rs => shared/src/lib.rs +1 -14
@@ 6,17 6,4 @@
 * See LICENSE for licensing information.
 */

pub fn add(left: usize, right: usize) -> usize {
    left + right
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn it_works() {
        let result = add(2, 2);
        assert_eq!(result, 4);
    }
}
pub mod server;

A shared/src/server/channels.rs => shared/src/server/channels.rs +15 -0
@@ 0,0 1,15 @@
/*
 * This file is part of laurelin/shared
 * Copyright (C) 2023 Jonni Liljamo <jonni@liljamo.com>
 *
 * Licensed under GPL-3.0-only.
 * See LICENSE for licensing information.
 */

use naia_bevy_shared::{Protocol, ProtocolPlugin};

pub struct ChannelsPlugin;

impl ProtocolPlugin for ChannelsPlugin {
    fn build(&self, protocol: &mut Protocol) {}
}

A shared/src/server/messages/mod.rs => shared/src/server/messages/mod.rs +15 -0
@@ 0,0 1,15 @@
/*
 * This file is part of laurelin/shared
 * Copyright (C) 2023 Jonni Liljamo <jonni@liljamo.com>
 *
 * Licensed under GPL-3.0-only.
 * See LICENSE for licensing information.
 */

use naia_bevy_shared::{Protocol, ProtocolPlugin};

pub struct MessagesPlugin;

impl ProtocolPlugin for MessagesPlugin {
    fn build(&self, protocol: &mut Protocol) {}
}

A shared/src/server/mod.rs => shared/src/server/mod.rs +12 -0
@@ 0,0 1,12 @@
/*
 * This file is part of laurelin/shared
 * Copyright (C) 2023 Jonni Liljamo <jonni@liljamo.com>
 *
 * Licensed under GPL-3.0-only.
 * See LICENSE for licensing information.
 */

pub mod channels;
pub mod messages;

pub mod protocol;

A shared/src/server/protocol.rs => shared/src/server/protocol.rs +25 -0
@@ 0,0 1,25 @@
/*
 * This file is part of laurelin/shared
 * Copyright (C) 2023 Jonni Liljamo <jonni@liljamo.com>
 *
 * Licensed under GPL-3.0-only.
 * See LICENSE for licensing information.
 */

use std::time::Duration;

use naia_bevy_shared::{LinkConditionerConfig, Protocol};

use super::{channels::ChannelsPlugin, messages::MessagesPlugin};

pub fn protocol() -> Protocol {
    Protocol::builder()
        // configuration
        .tick_interval(Duration::from_millis(25))
        .link_condition(LinkConditionerConfig::average_condition())
        // channels
        .add_plugin(ChannelsPlugin)
        // messages
        .add_plugin(MessagesPlugin)
        .build()
}