aboutsummaryrefslogtreecommitdiff
path: root/examples/statetracker/src/server.rs
diff options
context:
space:
mode:
authorMax Audron <audron@cocaine.farm>2021-09-28 17:57:08 +0200
committerMax Audron <audron@cocaine.farm>2021-09-28 17:59:28 +0200
commit94274c55189db5daf9f51e6db5df3ea23a530876 (patch)
tree761329c33fd75ad52e294c86d51558c4d2302e42 /examples/statetracker/src/server.rs
parentstatetracker: first iteration of working rpc object (diff)
statetracker: cleanup code
Diffstat (limited to 'examples/statetracker/src/server.rs')
-rw-r--r--examples/statetracker/src/server.rs31
1 files changed, 24 insertions, 7 deletions
diff --git a/examples/statetracker/src/server.rs b/examples/statetracker/src/server.rs
index ac9c550..6d56662 100644
--- a/examples/statetracker/src/server.rs
+++ b/examples/statetracker/src/server.rs
@@ -1,16 +1,19 @@
use anyhow::{bail, Error};
+use std::convert::TryFrom;
+
use druid::{
widget::{
Align, Button, Checkbox, Container, Controller, ControllerHost, Flex, Label, TextBox,
},
- Command, Data, ExtEventSink, Lens, Target, Widget, WidgetExt,
+ Command, Data, ExtEventSink, Lens, SingleUse, Target, Widget, WidgetExt,
};
use libquassel::{
deserialize::Deserialize,
frame::QuasselCodec,
message::{self, objects, ConnAck, HandshakeMessage, Init},
+ primitive::VariantMap,
};
use futures::{
@@ -130,7 +133,7 @@ impl Server {
.unwrap(),
};
- ctx.submit_command(command::ADD_MESSAGE, msg, Target::Global)
+ ctx.submit_command(command::ADD_MESSAGE, SingleUse::new(msg), Target::Global)
.unwrap();
}
}
@@ -170,16 +173,30 @@ impl Server {
match message::Message::parse(buf) {
Ok((_size, res)) => {
+ let re = res.clone();
+
#[allow(unused_variables)]
- match &res {
- message::Message::SyncMessage(msg) => (),
+ match res {
+ message::Message::SyncMessage(msg) => match msg.class_name.as_str() {
+ "AliasManager" => match msg.slot_name.as_str() {
+ "update" => ctx
+ .submit_command(
+ command::ALIASMANAGER_UPDATE,
+ SingleUse::new(msg),
+ Target::Global,
+ )
+ .unwrap(),
+ _ => (),
+ },
+ _ => (),
+ },
message::Message::RpcCall(msg) => (),
message::Message::InitRequest(msg) => (),
- message::Message::InitData(msg) => match &msg.init_data {
+ message::Message::InitData(msg) => match msg.init_data {
objects::Types::AliasManager(alias_manager) => ctx
.submit_command(
command::ALIASMANAGER_INIT,
- alias_manager.clone(),
+ SingleUse::new(alias_manager),
Target::Global,
)
.unwrap(),
@@ -189,7 +206,7 @@ impl Server {
message::Message::HeartBeatReply(msg) => (),
}
- return Ok(Message::SignalProxy(res));
+ return Ok(Message::SignalProxy(re));
}
Err(e) => {
bail!("failed to parse message {}", e);
852357&follow=1'>implement IdentityIdMax Audron-8/+79 2025-02-26refactor variant deserializationMax Audron-123/+59 2025-02-26refactor deserialize and serializevariant traitMax Audron-90/+80 move stuff around a bit to sepperate it out for deserializevariant 2025-02-26refactor variant serialization codeMax Audron-256/+405 Factored out a lot of the serialization of variants into trait's that have auto impl so code duplication is much reduced 2025-02-26add MsgId and BufferId to objects where neededMax Audron-141/+157 some objects where still handling BufferId or MsgId as their raw types which lead to errors now that the Types are properly parsed in the varinats 2025-02-25enable transparent repr for msgid and bufferidMax Audron-0/+2 2025-02-25Implement BacklogManagerTobias Deiminger-59/+113 2025-02-25Use BufferId in BufferInfoTobias Deiminger-10/+11 2025-02-25Use BufferId in VariantTobias Deiminger-2/+33 2025-02-25Add BufferId as Rust typeTobias Deiminger-0/+39 Up to now it was represented as i32. If we introduce a newtype for it, we can handle it idiomatically as dedicated Variant::BufferId variant (instead of having it mashed into Variant::UserType). 2025-02-25Use MsgId in MessageTobias Deiminger-18/+6 2025-02-25Use MsgId in VariantTobias Deiminger-20/+37 2025-02-25Add MsgId as Rust typeTobias Deiminger-0/+56 Up to now it was handled implicitely in Variant::UserType. Making it an explicit type allows to centralize the i32/i64 cfg dependency and to use the type for arguments in signalproxy::objects functions. 2025-02-24added session manager comments and log messageMax Audron-1/+3 2025-02-23add identity syncable to SessionManagerMax Audron-1/+8 2025-02-23add syncables for IrcUserMax Audron-2/+53 2025-02-23move network config to it's own file and impl it's syncMax Audron-23/+84 2025-02-23add basic network syncablesMax Audron-39/+420 2025-02-23clean up unused_import and unused_variables a bitMax Audron-2/+8 2025-02-23fix server feature errorsMax Audron-28/+23 2025-02-23fix ircchannel and maplist network representationMax Audron-154/+137 2025-02-22replace deprecated failure crate with thiserrorMax Audron-278/+194 this changes the public API in that all our methods now return a proper ProtocolError crate. Needed change anyways to properly deal with all our errors in the long run. Will still need to do a pass through the crate to remove all existing unwraps where it makes sense. 2025-02-22update dependencies and fix errorsMax Audron-508/+332 2025-02-22update flakeMax Audron-94/+117 2024-05-22add todos to readmeMax Audron-16/+35