blob: 598d39ba8e37e7ffa07977d896562e913377276c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
// Copyleft 2021-2021 Whirlsplash
// SPDX-License-Identifier: GPL-3.0-only
use bytes::{BufMut, BytesMut};
use crate::{config::Config, server::cmd::constants::REDIRID};
pub fn create_room_id_request(room: &str, room_id: u8) -> Vec<u8> {
let mut command = BytesMut::new();
// Header
command.put_u8(0x01); // ObjId
command.put_u8(REDIRID as u8); // Type
// Content
command.put_u8(room.len() as u8); // Room name length
command.put_slice(room.as_bytes()); // Room name
// command.put_u8(0x00); // Unimplemented byte (?)
// command.put_u8(room_id); // Room ID
command.put_u16(room_id as u16); // Room ID
// IP
for byte in "0.0.0.0".split('.') {
command.put_u8(byte.parse::<u8>().unwrap());
}
command.put_u16(Config::get().unwrap().hub.port as u16); // Port
// Length
let mut command_as_vec = command.to_vec();
command_as_vec.insert(0, command.len() as u8 + 1);
// Return
command_as_vec
}
|