From 328bdf533ace498b04e99d52e3c844c3e0996b69 Mon Sep 17 00:00:00 2001 From: ntr Date: Wed, 17 Jul 2019 17:35:31 +1000 Subject: [PATCH] additional message types --- server/src/pubsub.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/server/src/pubsub.rs b/server/src/pubsub.rs index dd8e0a1c..f79e4861 100644 --- a/server/src/pubsub.rs +++ b/server/src/pubsub.rs @@ -48,11 +48,18 @@ pub enum Message { fn handle_notification(n: Notification, db: &Db, pss: &Sender) -> Result<(), Error> { info!("pubsub received notification notification={:?}", n); + // maybe we need it + let mut tx = db.transaction()?; + let msg = match n.table { Table::Accounts => Message::Account(account::select(db, n.id)?), - _ => unimplemented!(), + Table::Instances => Message::Instance(instance::instance_get(&mut tx, n.id)?), + Table::Games => Message::Game(game::game_get(&mut tx, n.id)?), + _ => return Err(format_err!("unimplemented notification {:?}", n)), }; + tx.commit()?; + match pss.try_send(msg.clone()) { Ok(()) => info!("pubsub message sent message={:?}", msg), Err(e) => warn!("pubsub delivery failure err={:?}", e),