mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2025-07-03 16:25:35 +00:00
heartbeat fixes + guest support
This commit is contained in:
parent
4e985bc0e0
commit
5097244c76
@ -60,8 +60,9 @@ async fn main() {
|
||||
let new_status = server.get_server_status();
|
||||
|
||||
if status != new_status {
|
||||
trace!("WHAT");
|
||||
status = new_status;
|
||||
hb_tx.send(status.clone());
|
||||
hb_tx.send(status.clone()).await;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,8 +40,7 @@ pub enum ClientState {
|
||||
|
||||
#[derive(Deserialize, Debug, PartialEq, Clone)]
|
||||
pub struct UserData {
|
||||
#[serde(deserialize_with = "deserialize_number_from_string")]
|
||||
pub uid: u64,
|
||||
pub uid: String,
|
||||
pub createdAt: String,
|
||||
pub guest: bool,
|
||||
pub roles: String,
|
||||
@ -127,12 +126,14 @@ impl Client {
|
||||
return Err(ClientError::AuthenticateError.into());
|
||||
}
|
||||
let mut json = HashMap::new();
|
||||
json.insert("key".to_string(), packet.data_as_string());
|
||||
let key = packet.data_as_string();
|
||||
debug!("[AUTH] key: {}", key);
|
||||
json.insert("key".to_string(), key);
|
||||
let user_data: UserData =
|
||||
authentication_request("pkToUser", json)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
error!("{:?}", e);
|
||||
error!("[AUTH] {:?}", e);
|
||||
e
|
||||
})?;
|
||||
debug!("user_data: {:?}", user_data);
|
||||
|
@ -71,7 +71,7 @@ fn load_plugins() -> Vec<Plugin> {
|
||||
plugins
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Clone, Debug)]
|
||||
#[derive(PartialEq, Eq, Clone, Debug)]
|
||||
pub struct ServerStatus {
|
||||
pub player_count: usize,
|
||||
pub player_list: String,
|
||||
@ -382,7 +382,7 @@ impl Server {
|
||||
.info
|
||||
.as_ref()
|
||||
.unwrap();
|
||||
(client.username.clone(), client.roles.clone(), client.guest, client.uid)
|
||||
(client.username.clone(), client.roles.clone(), client.guest, client.uid.clone())
|
||||
};
|
||||
info!("Welcome {name}!");
|
||||
joined_names.push(name.clone());
|
||||
@ -391,7 +391,7 @@ impl Server {
|
||||
let (tx, rx) = tokio::sync::oneshot::channel();
|
||||
plugin.send_event(PluginBoundPluginEvent::CallEventHandler((ScriptEvent::OnPlayerAuthenticated { name: name.clone(), role: role.clone(), is_guest, identifiers: PlayerIdentifiers {
|
||||
ip: String::from("not yet implemented"),
|
||||
beammp_id,
|
||||
beammp_id: beammp_id.clone(),
|
||||
} }, Some(tx)))).await;
|
||||
// TODO: This never returns, because it blocks the entire process function
|
||||
// from running, so it never manages to run the function correctly.
|
||||
|
@ -30,14 +30,14 @@ pub enum Argument {
|
||||
#[derive(Debug)]
|
||||
pub struct PlayerIdentifiers {
|
||||
pub ip: String,
|
||||
pub beammp_id: u64,
|
||||
pub beammp_id: String,
|
||||
}
|
||||
|
||||
impl PlayerIdentifiers {
|
||||
pub fn to_map(&self) -> HashMap<String, Argument> {
|
||||
let mut m = HashMap::new();
|
||||
m.insert(String::from("ip"), Argument::String(self.ip.clone()));
|
||||
m.insert(String::from("beammp"), Argument::Integer(self.beammp_id as i64)); // TODO: Uhh we could lose data here
|
||||
m.insert(String::from("beammp"), Argument::String(self.beammp_id.clone()));
|
||||
m
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user