diff options
| author | Fuwn <[email protected]> | 2021-07-01 01:00:39 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2021-07-01 01:00:39 +0000 |
| commit | 1bde0e36add2407db32987189705a1b5f2c1678a (patch) | |
| tree | da0acd085e775455fb633750ffe45727ee92558b | |
| parent | feat(whirl_server): create the SESSEXIT command (diff) | |
| download | whirl-1bde0e36add2407db32987189705a1b5f2c1678a.tar.xz whirl-1bde0e36add2407db32987189705a1b5f2c1678a.zip | |
feat(whirl_server): implement SESSEXIT command
| -rw-r--r-- | crates/whirl_server/src/distributor.rs | 19 | ||||
| -rw-r--r-- | crates/whirl_server/src/hub.rs | 19 |
2 files changed, 34 insertions, 4 deletions
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]); |