better prompt text

This commit is contained in:
ntr
2020-01-10 13:09:47 +10:00
parent b3b5716b21
commit 37a491b21a
9 changed files with 26 additions and 35 deletions
+1 -19
View File
@@ -141,24 +141,6 @@ struct Connection {
events: CbSender<Event>,
}
impl Connection {
// this is where last minute processing happens
// use it to modify outgoing messages, update subs, serialize in some way...
fn send(&self, msg: RpcMessage) -> Result<(), Error> {
let msg = match msg {
RpcMessage::InstanceState(v) => RpcMessage::InstanceState(v.redact(self.id)),
RpcMessage::AccountInstances(v) =>
RpcMessage::AccountInstances(v.into_iter().map(|i| i.redact(self.id)).collect()),
RpcMessage::GameState(v) => RpcMessage::GameState(v.redact(self.id)),
_ => msg,
};
self.ws.send(msg).unwrap();
Ok(())
}
}
// we unwrap everything in here cause really
// we don't care if this panics
// it's run in a thread so it's supposed to bail
@@ -178,7 +160,7 @@ impl Handler for Connection {
},
Err(e) => {
warn!("{:?}", e);
self.send(RpcMessage::Error(e.to_string())).unwrap();
self.ws.send(RpcMessage::Error(e.to_string())).unwrap();
},
};
},
+10
View File
@@ -50,6 +50,16 @@ impl User for Anonymous {
_ => (),
};
// last minute redactions and processing
// this happens after the state setting as we need to keep
// all the skills to prevent forfeiting
let msg = match msg {
RpcMessage::InstanceState(v) => RpcMessage::InstanceState(v.redact(self.id)),
RpcMessage::GameState(v) => RpcMessage::GameState(v.redact(self.id)),
_ => msg,
};
self.ws.send(msg)?;
Ok(())
+9
View File
@@ -79,6 +79,15 @@ impl User for Authenticated {
_ => (),
};
// last minute processing
let msg = match msg {
RpcMessage::InstanceState(v) => RpcMessage::InstanceState(v.redact(self.id)),
RpcMessage::AccountInstances(v) =>
RpcMessage::AccountInstances(v.into_iter().map(|i| i.redact(self.id)).collect()),
RpcMessage::GameState(v) => RpcMessage::GameState(v.redact(self.id)),
_ => msg,
};
self.ws.send(msg)?;
Ok(())