use std::sync::Arc;
use axum::Json;
use dashmap::{DashMap};
use lazy_static::lazy_static;
use serde_json::{json, Value};
pub trait testServer {
fn getOneBronAndCamp(&mut self) ->Json;
}
pub struct RoomServer{
pub BattleTime:f32,
pub sceneId:String,
}
impl testServer for RoomServer{
fn getOneBronAndCamp(&mut self) ->Json {
Json(json!({ "camp": 1, "pos":{"x":30.0, "y":self.BattleTime, "z":60.5}, "index":2}))
}
}
lazy_static!{
pub static ref roomList:Arc<DashMap<String, RoomServer>> = Arc::new(DashMap::new());
}
fn main() {
roomList.insert(String::from("1") , RoomServer { BattleTime: 10.5, sceneId: String::from("852963") });
roomList.insert(String::from("2") , RoomServer { BattleTime: 10.7, sceneId: String::from("741852") });
roomList.insert(String::from("3") , RoomServer { BattleTime: 10.6, sceneId: String::from("753159") });
for item in roomList.iter() {
println!("{}", item.value().sceneId);
}
let v = roomList.get("1");
let binding = v.unwrap();
let roomServer = binding.value();
let info = roomServer.getOneBronAndCamp();
loop {
}
}