Working on sync 2 more

This commit is contained in:
Dessalines 2020-04-17 12:57:16 -04:00
parent fa5b1caa84
commit 6a6ed19cc6

View file

@ -443,37 +443,35 @@ impl Handler<Disconnect> for ChatServer {
} }
} }
// type DeferredStandardMessage = MessageResult<StandardMessage>;
/// Handler for Message message. /// Handler for Message message.
impl Handler<StandardMessage> for ChatServer { impl Handler<StandardMessage> for ChatServer {
type Result = MessageResult<StandardMessage>; // type Result = MessageResult<StandardMessage>;
type Result = ResponseActFuture<Self, MessageResult<StandardMessage>>;
fn handle(&mut self, msg: StandardMessage, ctx: &mut Context<Self>) { fn handle(&mut self, msg: StandardMessage, ctx: &mut Context<Self>) -> Self::Result {
let my_block = async move { Box::new(async move {
self.db_handle.run(|conn| { self.db_handle.run(|conn| {
parse_json_message(&mut self.clone(), msg.clone(), &conn) parse_json_message(self, msg, &conn)
// match parse_json_message(self, msg, &conn) { });
}
.into_actor(self).map(|res, actor, ctx| {
// match res {
// Ok(m) => { // Ok(m) => {
// info!("Message Sent: {}", m); // info!("Message Sent: {}", m);
// MessageResult(m) // MessageResult(m);
// } // Ok(())
// },
// Err(e) => { // Err(e) => {
// error!("Error during message handling {}", e); // error!("Error during message handling {}", e);
// MessageResult(e.to_string()) // MessageResult(e.to_string());
// } // Err(())
// } // },
}).await // Ok(())
}; MessageResult("hi".to_string())
}))
let actor_future = my_block
.into_actor(self)
.map(|res, actor, ctx| {
});
ctx.spawn(actor_future);
} }
} }