make slp use a template

This commit is contained in:
ElementG9 2020-08-18 12:56:19 -06:00
parent a142e73d67
commit 17e9e7dd61
2 changed files with 17 additions and 21 deletions

View File

@ -38,3 +38,12 @@
[2020-08-18 08:15:48][Composition::net][INFO] Network server started!
[2020-08-18 08:15:48][Composition][INFO] Done! Start took 1.853066ms
[2020-08-18 08:15:55][Composition::net][INFO] Got client at 127.0.0.1:56532
[2020-08-18 12:50:04][Composition][INFO] Starting server...
[2020-08-18 12:50:04][Composition::net][INFO] Network server started!
[2020-08-18 12:50:04][Composition][INFO] Done! Start took 1.983874ms
[2020-08-18 12:50:23][Composition::net][INFO] Got client at 127.0.0.1:62307
[2020-08-18 12:50:33][Composition::net][INFO] Got client at 127.0.0.1:62319
[2020-08-18 12:55:34][Composition][INFO] Starting server...
[2020-08-18 12:55:34][Composition::net][INFO] Network server started!
[2020-08-18 12:55:34][Composition][INFO] Done! Start took 1.130267ms
[2020-08-18 12:55:56][Composition::net][INFO] Got client at 127.0.0.1:62750

View File

@ -95,27 +95,14 @@ impl NetworkClient {
let statusrequest = StatusRequest::read(&mut self.stream).unwrap();
println!("{:?}", statusrequest);
let mut statusresponse = StatusResponse::new();
statusresponse.json_response = r#"{
"version": {
"name": "1.8.7",
"protocol": 47
},
"players": {
"max": 100,
"online": 5,
"sample": [
{
"name": "thinkofdeath",
"id": "4566e69f-c907-48ee-8d71-d7ba5aa00d20"
}
]
},
"description": {
"text": "Hello world"
},
"sample": ""
}"#
.into();
statusresponse.json_response = format!(
"{{\n\t\"version\": {{\n\t\t\"name\": \"{server_version}\",\n\t\t\"protocol\": {server_protocol}\n\t}},\n\t\"players\": {{\n\t\t\"max\": {max_players},\n\t\t\"online\": {num_players},\n\t\t\"sample\": [\n\t\t\t{{\n\t\t\t\t\"name\": \"ElementG9\",\n\t\t\t\t\"id\": \"e3f58380-60bb-4714-91f2-151d525e64aa\"\n\t\t\t}}\n\t\t]\n\t}},\n\t\"description\": {{\n\t\t\"text\": \"{server_description}\"\n\t}},\n\t\"sample\": \"\"\n}}",
server_version = "1.8.9",
server_protocol = 47,
num_players = 5,
max_players = 100,
server_description = "Hello world!"
).into();
statusresponse.write(&mut self.stream).unwrap();
println!("{:?}", statusresponse);
let (_packet_length, _packet_id) = read_packet_header(&mut self.stream).unwrap();