aboutsummaryrefslogtreecommitdiff
path: root/src/server/auto/cmd
diff options
context:
space:
mode:
authorFuwn <[email protected]>2021-03-25 22:20:21 +0000
committerFuwn <[email protected]>2021-03-25 22:20:21 +0000
commit5fc28bfb2851441893ef2ad5f72e0feb8a0a22cc (patch)
treef39b7bccc486298b1b7f4945cad37b4839817b73 /src/server/auto/cmd
parentfeature: Byte utilities (diff)
downloadwhirl-5fc28bfb2851441893ef2ad5f72e0feb8a0a22cc.tar.xz
whirl-5fc28bfb2851441893ef2ad5f72e0feb8a0a22cc.zip
major: Publish work-in-progress
Diffstat (limited to 'src/server/auto/cmd')
-rw-r--r--src/server/auto/cmd/mod.rs1
-rw-r--r--src/server/auto/cmd/property.rs36
-rw-r--r--src/server/auto/cmd/room.rs7
-rw-r--r--src/server/auto/cmd/session.rs18
4 files changed, 27 insertions, 35 deletions
diff --git a/src/server/auto/cmd/mod.rs b/src/server/auto/cmd/mod.rs
index 5430662..d2345c6 100644
--- a/src/server/auto/cmd/mod.rs
+++ b/src/server/auto/cmd/mod.rs
@@ -1,2 +1,3 @@
pub mod property;
pub mod room;
+pub mod session;
diff --git a/src/server/auto/cmd/property.rs b/src/server/auto/cmd/property.rs
index 01d4f43..b8d0085 100644
--- a/src/server/auto/cmd/property.rs
+++ b/src/server/auto/cmd/property.rs
@@ -1,38 +1,4 @@
-// struct NetToProperty {
-// _prop_id: i32,
-// _flags: i32,
-// _access: i32,
-// _string_value: String,
-// _bin_value: Vec<i32>,
-// }
-// impl NetToProperty {
-// fn parse_net_data() -> Self {
-// NetToProperty {
-// _prop_id: 0,
-// _flags: 0,
-// _access: 0,
-// _string_value: "".to_string(),
-// _bin_value: vec![]
-// }
-// }
-// }
-
-// TODO: Decode received data and send back a valid response.
-pub fn create_property_update_command() -> [u8; 147] { // Vec<u8>
- // let mut property = Vec::with_capacity(2);
- // property.push(0x01); // ?
- // property.push(0x10); // Command type
- //
- // // Meaningful Data
- // property.push(); // Property ID
- // property.push(); // Flags
- // property.push(); // Access
- //
- // // Insert data length as first byte.
- // property.insert(0, property.len() as u8 + 1); // ^
- //
- // property // Return created array
-
+pub fn create_property_update_command() -> [u8; 147] {
[
0x93, 0xFF, 0x10, 0x1B, 0x80, 0x01, 0x0C, 0x77, 0x6F,
0x72, 0x6C, 0x64, 0x73, 0x33, 0x64, 0x2E, 0x63, 0x6F,
diff --git a/src/server/auto/cmd/room.rs b/src/server/auto/cmd/room.rs
index ff839f3..78498fe 100644
--- a/src/server/auto/cmd/room.rs
+++ b/src/server/auto/cmd/room.rs
@@ -18,6 +18,13 @@ pub fn create_room_id_redirect_command(room_name: &str, room_id: usize) -> Vec<u
room_id_redirect.push(0x00);
// Port
+ // for byte in convert_u16_to_two_u8s_be(0x1629).iter() {
+ // room_id_redirect.push(*byte);
+ // }
+ // Port
+ // for byte in convert_u16_to_two_u8s_be(5673_i32 as u16).iter() {
+ // room_id_redirect.push(*byte);
+ // }
room_id_redirect.push(0x16);
room_id_redirect.push(0x29);
diff --git a/src/server/auto/cmd/session.rs b/src/server/auto/cmd/session.rs
new file mode 100644
index 0000000..8e8fbb7
--- /dev/null
+++ b/src/server/auto/cmd/session.rs
@@ -0,0 +1,18 @@
+use crate::server::cmd::session::SessionInitializationCommand;
+use bytes::BytesMut;
+use std::str::from_utf8;
+
+pub fn parse_session_initialization_command(
+ command: BytesMut
+) -> SessionInitializationCommand {
+ SessionInitializationCommand {
+ // protocol: command.get(4..4 + command.get(4)).unwrap().to_owned() as usize,
+ // client: "".to_string(),
+ username: from_utf8(
+ command.get(
+ 21..(20 + command.get(20).unwrap().to_owned() as usize + 1)
+ ).unwrap()
+ ).unwrap().to_string(),
+ // password: "".to_string()
+ }
+}