listener : UnixListener,
}
+struct Who;
+impl Display for Who {
+ #[throws(fmt::Error)]
+ fn fmt(&self, f: &mut Formatter) { write!(f, "The facilitator")? }
+}
+
// ========== management API ==========
// ---------- management command implementations
use MgmtGameResponse::*;
type Insn = MgmtGameInstruction;
type Resp = MgmtGameResponse;
+ let who = &cs.who;
fn readonly(_ig: &InstanceGuard, resp: Resp) -> ExecuteGameInsnResults {
(U{ pcs: vec![], log: vec![], raw: None }, resp)
}
Err(ME::AlreadyExists)?;
}
let logentry = LogEntry {
- html: Html(format!("The facilitator added a player: {}",
+ html: Html(format!("{} added a player: {}", &who,
htmlescape::encode_minimal(&pl.nick))),
};
let (player, logentry) = ig.player_new(pl, logentry)?;
let old_state = ig.player_remove(player)?;
(U{ pcs: vec![],
log: old_state.iter().map(|pl| LogEntry {
- html: Html(format!("The facilitator removed a player: {}",
+ html: Html(format!("{} removed a player: {}", &who,
htmlescape::encode_minimal(&pl.nick))),
}).collect(),
raw: None},
(U{ pcs: updates,
log: vec![ LogEntry {
- html: Html(format!("The facilitator added {} pieces",
- count)),
+ html: Html(format!("{} added {} pieces", &who, count)),
}],
raw: None },
Fine)
}
#[throws(SVGProcessingError)]
- fn complete(self, _cs: &CommandStream, g: &mut InstanceGuard) {
+ fn complete(self, cs: &CommandStream, g: &mut InstanceGuard) {
use UpdateHandler::*;
match self {
Bulk(bulk) => {
if bulk.logs {
buf.log_updates(vec![LogEntry {
- html: Html::lit("The facilitator (re)configured the game")
+ html: Html(format!("{} (re)configured the game", &cs.who))
}]);
}
desc : &'d str,
scope : Option<ManagementScope>,
chan : MgmtChannel,
+ who: Who,
}
impl CommandStream<'_> {
let cs = CommandStream {
scope: None, desc: &desc,
chan, euid: euid.map(Uid::from_raw),
+ who: Who,
};
cs.mainloop()?;