From d1d904280703605444c9e32a67f984c04e4579f2 Mon Sep 17 00:00:00 2001 From: Lucas Schwiderski Date: Fri, 26 May 2023 22:03:12 +0200 Subject: [PATCH] WIP --- lib/dt_p2p/.gitignore | 2 -- lib/dt_p2p/src/lib.rs | 29 ++++++++++++++++++++--------- lib/nat_traversal/.gitignore | 2 -- lib/nat_traversal/src/ice/mod.rs | 1 + 4 files changed, 21 insertions(+), 13 deletions(-) delete mode 100644 lib/dt_p2p/.gitignore delete mode 100644 lib/nat_traversal/.gitignore create mode 100644 lib/nat_traversal/src/ice/mod.rs diff --git a/lib/dt_p2p/.gitignore b/lib/dt_p2p/.gitignore deleted file mode 100644 index 4fffb2f..0000000 --- a/lib/dt_p2p/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/target -/Cargo.lock diff --git a/lib/dt_p2p/src/lib.rs b/lib/dt_p2p/src/lib.rs index 148bb9f..93bbf13 100644 --- a/lib/dt_p2p/src/lib.rs +++ b/lib/dt_p2p/src/lib.rs @@ -1,16 +1,26 @@ +use std::{ + ffi::{c_char, CString}, + sync::RwLock, +}; + mod stingray_sdk; -use std::ffi::c_char; -use std::ffi::CString; - -use stingray_sdk::GetApiFunction; -use stingray_sdk::PluginApi; -use stingray_sdk::PluginApiID; - -use crate::stingray_sdk::LoggingApi; +use crate::stingray_sdk::{GetApiFunction, LoggingApi, PluginApi, PluginApiID}; const PLUGIN_NAME: &str = "dt_p2p"; +struct Plugin { + log: Option, +} + +impl Plugin { + pub const fn new() -> Self { + Self { log: None } + } +} + +static PLUGIN: RwLock = RwLock::new(Plugin::new()); + #[no_mangle] pub extern "C" fn get_name() -> *const c_char { let s = CString::new(PLUGIN_NAME).expect("Failed to create CString from plugin name"); @@ -21,7 +31,8 @@ pub extern "C" fn get_name() -> *const c_char { pub extern "C" fn setup_game(get_engine_api: GetApiFunction) { println!("setup_game"); - let log = LoggingApi::get(get_engine_api); + PLUGIN.log = Some(LoggingApi::get(get_engine_api)); + let log = PLUGIN.log.as_ref().unwrap(); log.info( PLUGIN_NAME, diff --git a/lib/nat_traversal/.gitignore b/lib/nat_traversal/.gitignore deleted file mode 100644 index 4fffb2f..0000000 --- a/lib/nat_traversal/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/target -/Cargo.lock diff --git a/lib/nat_traversal/src/ice/mod.rs b/lib/nat_traversal/src/ice/mod.rs new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/lib/nat_traversal/src/ice/mod.rs @@ -0,0 +1 @@ +