Fixed plugin loader dir not found

This commit is contained in:
2025-12-22 21:41:30 +01:00
parent 33f04aeeee
commit aa8996d79a
+16 -9
View File
@@ -70,17 +70,24 @@ impl PluginLoader {
let plugin_clients = self.plugin_clients.clone(); let plugin_clients = self.plugin_clients.clone();
let listener = TcpListener::bind("0.0.0.0:7243").unwrap(); let listener = TcpListener::bind("0.0.0.0:7243").unwrap();
let handle_plugin = move |stream: Result<TcpStream, std::io::Error>| -> crate::Result<()> {
let stream = stream?;
let mut reader = BufReader::new(&stream);
let mut s = String::new();
reader.read_line(&mut s)?;
let plugin_handshake: PluginHandshake = serde_json::from_str(&s)?;
plugin_clients
.lock()
.unwrap()
.insert(plugin_handshake.id, stream);
Ok(())
};
std::thread::spawn(move || { std::thread::spawn(move || {
for stream in listener.incoming() { for stream in listener.incoming() {
let stream = stream.unwrap(); if let Err(e) = handle_plugin(stream) {
let mut reader = BufReader::new(&stream); LOGGER.error(format!("Plugin error: {e}"));
let mut s = String::new(); }
reader.read_line(&mut s).unwrap();
let plugin_handshake: PluginHandshake = serde_json::from_str(&s).unwrap();
plugin_clients
.lock()
.unwrap()
.insert(plugin_handshake.id, stream);
} }
}); });
} }