diff options
| -rw-r--r-- | crates/whirl_server/src/cmd/commands/mod.rs | 1 | ||||
| -rw-r--r-- | crates/whirl_server/src/cmd/commands/session_exit.rs | 12 | ||||
| -rw-r--r-- | crates/whirl_server/src/distributor.rs | 19 | ||||
| -rw-r--r-- | crates/whirl_server/src/hub.rs | 19 | ||||
| -rw-r--r-- | crates/whirl_server/src/net/network_property.rs | 1 | ||||
| -rw-r--r-- | crates/whirl_server/src/net/property_list.rs | 1 |
6 files changed, 49 insertions, 4 deletions
diff --git a/crates/whirl_server/src/cmd/commands/mod.rs b/crates/whirl_server/src/cmd/commands/mod.rs index 884729d..7f8bb4a 100644 --- a/crates/whirl_server/src/cmd/commands/mod.rs +++ b/crates/whirl_server/src/cmd/commands/mod.rs @@ -6,6 +6,7 @@ pub mod buddy_list; pub mod property; pub mod redirect_id; pub mod room_id_request; +pub mod session_exit; pub mod subscribe_distance; pub mod subscribe_room; pub mod teleport; diff --git a/crates/whirl_server/src/cmd/commands/session_exit.rs b/crates/whirl_server/src/cmd/commands/session_exit.rs new file mode 100644 index 0000000..47048ab --- /dev/null +++ b/crates/whirl_server/src/cmd/commands/session_exit.rs @@ -0,0 +1,12 @@ +// Copyright (C) 2021-2021 The Whirlsplash Collective +// SPDX-License-Identifier: GPL-3.0-only + +use crate::{ + cmd::{constants::Command, extendable::Creatable}, + net::property_list::PropertyList, +}; + +pub struct SessionExit(pub PropertyList); +impl Creatable for SessionExit { + fn create(&self) -> Vec<u8> { self.0.clone().as_bytes(Command::SessExit as i32, 0x01) } +} diff --git a/crates/whirl_server/src/distributor.rs b/crates/whirl_server/src/distributor.rs index 13b13e6..85d6e61 100644 --- a/crates/whirl_server/src/distributor.rs +++ b/crates/whirl_server/src/distributor.rs @@ -27,13 +27,18 @@ use crate::{ property::create::{property_request_as_distributor, property_update_as_distributor}, redirect_id::RedirectId, room_id_request::RoomIdRequest, + session_exit::SessionExit, text::Text, }, constants::Command, extendable::{Creatable, Parsable}, }, interaction::{peer::Peer, shared::Shared}, - net::constants::VAR_USERNAME, + net::{ + constants::{VAR_ERROR, VAR_USERNAME}, + network_property::NetworkProperty, + property_list::PropertyList, + }, packet_parser::parse_commands_from_packet, Server, }; @@ -120,7 +125,17 @@ impl Server for Distributor { trace!("sent redirect id to {}: {}", username, room.room_name); } Some(Command::SessExit) => { - debug!("received session exit from {}", username); break; + debug!("received session exit from {}", username); + + peer.bytes.get_mut().write_all(&SessionExit(PropertyList(vec![ + NetworkProperty { + prop_id: VAR_ERROR, + value: "0".to_string(), + } + ])).create()).await?; + trace!("sent session exit to {}", username); + + break; } _ => {}, } diff --git a/crates/whirl_server/src/hub.rs b/crates/whirl_server/src/hub.rs index d823d1c..1c7fe6e 100644 --- a/crates/whirl_server/src/hub.rs +++ b/crates/whirl_server/src/hub.rs @@ -22,6 +22,7 @@ use crate::{ action::create, buddy_list::BuddyList, property::create::{property_request_as_hub, property_update_as_hub}, + session_exit::SessionExit, subscribe_distance::SubscribeDistance, subscribe_room::SubscribeRoom, teleport::Teleport, @@ -31,7 +32,11 @@ use crate::{ extendable::{Creatable, Parsable, ParsableWithArguments}, }, interaction::{peer::Peer, shared::Shared}, - net::constants::VAR_USERNAME, + net::{ + constants::{VAR_ERROR, VAR_USERNAME}, + network_property::NetworkProperty, + property_list::PropertyList, + }, packet_parser::parse_commands_from_packet, Server, }; @@ -105,7 +110,17 @@ impl Server for Hub { // trace!("{:?}", create_room_id_request(&room.room_name, 0x00)); // } Some(Command::SessExit) => { - debug!("received session exit from {}", username); break; + debug!("received session exit from {}", username); + + peer.bytes.get_mut().write_all(&SessionExit(PropertyList(vec![ + NetworkProperty { + prop_id: VAR_ERROR, + value: "0".to_string(), + } + ])).create()).await?; + trace!("sent session exit to {}", username); + + break; } Some(Command::Text) => { let text = Text::parse(msg.to_vec(), &[&username]); diff --git a/crates/whirl_server/src/net/network_property.rs b/crates/whirl_server/src/net/network_property.rs index 55800a0..c8d9046 100644 --- a/crates/whirl_server/src/net/network_property.rs +++ b/crates/whirl_server/src/net/network_property.rs @@ -1,6 +1,7 @@ // Copyright (C) 2021-2021 The Whirlsplash Collective // SPDX-License-Identifier: GPL-3.0-only +#[derive(Clone)] pub struct NetworkProperty { pub prop_id: i32, pub value: String, diff --git a/crates/whirl_server/src/net/property_list.rs b/crates/whirl_server/src/net/property_list.rs index 2c52132..a1c4b34 100644 --- a/crates/whirl_server/src/net/property_list.rs +++ b/crates/whirl_server/src/net/property_list.rs @@ -12,6 +12,7 @@ use crate::{ }, }; +#[derive(Clone)] pub struct PropertyList(pub Vec<crate::net::network_property::NetworkProperty>); impl PropertyList { /// Convert a `PropertyList` to a ready-to-be sent command. |