Improved structure

This commit is contained in:
2025-09-14 14:20:36 +02:00
parent 59e96fe05e
commit a4ce0c0589
17 changed files with 357 additions and 321 deletions
+28 -1
View File
@@ -1,5 +1,5 @@
use std::sync::Arc;
use voxa_server::{Server, export_plugin, logger, plugin::Plugin};
use voxa_server::{Server, export_plugin, logger, utils::plugin::Plugin};
logger! {
const LOGGER "My Plugin"
@@ -12,6 +12,33 @@ impl Plugin for MyPlugin {
fn init(&mut self, _server: &Arc<Server>) {
LOGGER.info("MyPlugin initialized!");
}
fn on_request(
&mut self,
msg: &voxa_server::types::WsMessage<voxa_server::types::ClientMessage>,
client: &voxa_server::utils::client::Client,
_server: &Arc<Server>,
) -> bool {
LOGGER.info(&format!("Received message: {:?}", msg));
match msg {
voxa_server::types::WsMessage::Message(
voxa_server::types::ClientMessage::SendMessage { contents, .. },
) => {
if contents == "ping" {
LOGGER.info("Pong!");
client
.send(voxa_server::types::ServerMessage::TempMessage {
message: "pong".to_string(),
})
.unwrap();
true
} else {
false
}
}
_ => false,
}
}
}
export_plugin!(Box::new(MyPlugin));
+1 -1
View File
@@ -1,6 +1,6 @@
use std::path::PathBuf;
use voxa_server::{ServerConfig, vfs};
use voxa_server::{ServerConfig, utils::vfs};
fn main() -> voxa_server::Result<()> {
let root = PathBuf::from("./");