36 lines
656 B
Rust
36 lines
656 B
Rust
use std::net::SocketAddr;
|
|
|
|
use godot::prelude::*;
|
|
|
|
mod ui;
|
|
|
|
struct MyExtension;
|
|
|
|
#[gdextension]
|
|
unsafe impl ExtensionLibrary for MyExtension {}
|
|
|
|
#[derive(GodotClass)]
|
|
#[class(base=Node)]
|
|
struct NetworkManager {
|
|
base: Base<Node>,
|
|
}
|
|
|
|
pub const NETWORK_SINGLETON_NAME: &str = "NetworkManagerGlob";
|
|
|
|
#[godot_api]
|
|
impl INode for NetworkManager {
|
|
fn init(base: Base<Node>) -> Self {
|
|
NetworkManager { base }
|
|
}
|
|
}
|
|
|
|
impl NetworkManager {
|
|
pub fn host(&mut self, port: u32) {
|
|
godot_print!("Hosting server at {}", port);
|
|
}
|
|
|
|
pub fn join(&mut self, addr: SocketAddr) {
|
|
godot_print!("Joining server at {:?}", addr);
|
|
}
|
|
}
|