mirror of
https://github.com/MedzikUser/servers
synced 2024-08-14 23:57:48 +00:00
Client
change async fn
to fn
, because async
is not used
This commit is contained in:
parent
5fbb153f8e
commit
01f6ed8ad8
6 changed files with 7 additions and 8 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -297,9 +297,9 @@ checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio"
|
name = "tokio"
|
||||||
version = "1.19.0"
|
version = "1.19.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0f392c8f16bda3456c0b00c6de39cb100449b98de55ac41c6cdd2bfcf53a1245"
|
checksum = "95eec79ea28c00a365f539f1961e9278fbcaf81c0ff6aaf0e93c181352446948"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"num_cpus",
|
"num_cpus",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
|
|
|
@ -13,4 +13,4 @@ clap = { version = "3.1.18", features = ["derive"] }
|
||||||
libloading = "0.7.3"
|
libloading = "0.7.3"
|
||||||
log = { version = "0.4.17", features = ["release_max_level_info", "max_level_trace"] }
|
log = { version = "0.4.17", features = ["release_max_level_info", "max_level_trace"] }
|
||||||
simple_logger = { version = "2.1.0", default-features = false, features = ["colors"] }
|
simple_logger = { version = "2.1.0", default-features = false, features = ["colors"] }
|
||||||
tokio = { version = "1.19.0", features = ["rt-multi-thread", "macros"] }
|
tokio = { version = "1.19.1", features = ["rt-multi-thread", "macros"] }
|
||||||
|
|
|
@ -28,7 +28,7 @@ impl Command for PluginTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn execute(&self, client: &mut Client, _args: Vec<&str>, _commands: &CommandManagerType) {
|
async fn execute(&self, client: &mut Client, _args: Vec<&str>, _commands: &CommandManagerType) {
|
||||||
client.send("content").await.expect("send message")
|
client.send("content").expect("send message")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,6 @@ impl Command for CommandHelp {
|
||||||
for command in command_manager.commands.iter() {
|
for command in command_manager.commands.iter() {
|
||||||
client
|
client
|
||||||
.send(&format!("{} - {}", command.name(), command.help()))
|
.send(&format!("{} - {}", command.name(), command.help()))
|
||||||
.await
|
|
||||||
.expect("send message");
|
.expect("send message");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ impl Client {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Read message/buffer from Client
|
/// Read message/buffer from Client
|
||||||
pub async fn read(&mut self) -> anyhow::Result<String> {
|
pub fn read(&mut self) -> anyhow::Result<String> {
|
||||||
// allocate an empty buffer of length 1024 bytes
|
// allocate an empty buffer of length 1024 bytes
|
||||||
let mut buf = [0; 1024];
|
let mut buf = [0; 1024];
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ impl Client {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Send message to Client
|
/// Send message to Client
|
||||||
pub async fn send(&mut self, content: &str) -> io::Result<()> {
|
pub fn send(&mut self, content: &str) -> io::Result<()> {
|
||||||
// add a new line at the end of the content
|
// add a new line at the end of the content
|
||||||
let content = format!("{content}\n\r");
|
let content = format!("{content}\n\r");
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ pub async fn handle_connection(
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
// read client message/buffer
|
// read client message/buffer
|
||||||
let buf = client.read().await?;
|
let buf = client.read()?;
|
||||||
|
|
||||||
// split message by whitespace
|
// split message by whitespace
|
||||||
let args: &Vec<&str> = &buf.split_ascii_whitespace().collect();
|
let args: &Vec<&str> = &buf.split_ascii_whitespace().collect();
|
||||||
|
|
Loading…
Reference in a new issue