Testing new session server

This commit is contained in:
2026-02-23 00:36:24 +01:00
parent 9b554aa510
commit 56fb719cca
5 changed files with 742 additions and 32 deletions
+26 -2
View File
@@ -1,3 +1,27 @@
fn main() {
println!("Hello, world!");
use session_rs::server::SessionServer;
use crate::methods::AuthResponse;
pub mod methods;
#[tokio::main(flavor = "current_thread")]
async fn main() -> session_rs::Result<()> {
let server = SessionServer::bind("127.0.0.1:8080").await?;
server
.session_loop(async |session, _| {
println!("Connected");
session
.on::<methods::Auth, _>(|_, req| async {
Ok(AuthResponse {
cloak: String::new(),
hat: String::new(),
cloaks: Vec::new(),
hats: Vec::new(),
})
})
.await;
Ok(())
})
.await
}
+60
View File
@@ -0,0 +1,60 @@
use serde::{Deserialize, Serialize};
use session_rs::Method;
#[derive(Debug, Serialize, Deserialize)]
pub struct AuthResponse {
pub cloak: String,
pub hat: String,
pub cloaks: Vec<String>,
pub hats: Vec<String>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct Auth;
impl Method for Auth {
const NAME: &'static str = "auth";
type Request = String;
type Response = AuthResponse;
type Error = String;
}
#[derive(Debug, Serialize, Deserialize)]
pub struct SetCloak;
impl Method for SetCloak {
const NAME: &'static str = "set_cloak";
type Request = String;
type Response = String;
type Error = String;
}
#[derive(Debug, Serialize, Deserialize)]
pub struct SetHat;
impl Method for SetHat {
const NAME: &'static str = "set_cloak";
type Request = String;
type Response = String;
type Error = String;
}
#[derive(Debug, Serialize, Deserialize)]
pub struct BuyCloak;
impl Method for BuyCloak {
const NAME: &'static str = "set_cloak";
type Request = String;
type Response = String;
type Error = String;
}
#[derive(Debug, Serialize, Deserialize)]
pub struct BuyHat;
impl Method for BuyHat {
const NAME: &'static str = "set_cloak";
type Request = String;
type Response = String;
type Error = String;
}