From 5eb3adbe8a0b5f11ef36fe3199d2011684d40b47 Mon Sep 17 00:00:00 2001 From: Mitchell Date: Tue, 30 Jun 2020 14:19:13 +0100 Subject: [PATCH] fixed string return format --- src/server/commands/client_info.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/server/commands/client_info.rs diff --git a/src/server/commands/client_info.rs b/src/server/commands/client_info.rs new file mode 100644 index 0000000..fe001ec --- /dev/null +++ b/src/server/commands/client_info.rs @@ -0,0 +1,30 @@ +use crate::server::client::client_profile::Client; +//use crate::client_management::client_profile::Client; + +use std::sync::Mutex; +use std::sync::Arc; +use std::collections::HashMap; + +pub fn get_client_data(clients_ref: &Arc>>, data: &HashMap) -> String{ + let clients_hashmap = clients_ref.lock().unwrap(); + let uuid = data.get("uuid").unwrap(); + println!("uuid: {}", uuid); + + for (key, value) in clients_hashmap.iter(){ + println!("{}",key); + } + let client = clients_hashmap.get(uuid); + match client{ + Some(data) => { + let mut message = String::from("!success:"); + message.push_str(&" uuid:".to_string()); + message.push_str(&data.get_uuid().to_string()); + message.push_str(&" host:".to_string()); + message.push_str(&data.get_address().to_string()); + message.push_str(&" username:".to_string()); + message.push_str(&data.get_username().to_string()); + message + }, + None => String::from("client not online"), + } +}