From: Ian Jackson Date: Sat, 4 Jul 2020 18:37:28 +0000 (+0100) Subject: init confirmation send X-Git-Tag: otter-0.2.0~1461 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=8b926a656aa9175850c842924629d14d4d40159a;p=otter.git init confirmation send --- diff --git a/src/sse.rs b/src/sse.rs index defda945..267c284c 100644 --- a/src/sse.rs +++ b/src/sse.rs @@ -39,6 +39,7 @@ impl StableIndexOffset for UpdateId { struct UpdateReader { player : PlayerId, client : ClientId, + init_confirmation_send : iter::Once<()>, to_send : UpdateId, ami : Arc>, } @@ -58,6 +59,14 @@ impl Read for UpdateReader { let mut amig = self.ami.lock().map_err(|_| em("poison"))?; let orig_wanted = buf.len(); + if self.init_confirmation_send.next().is_some() { + write!(buf, r#" +event: commsworking +data: server online + +"#)?; + } + let pu = &mut amig.updates.get(self.player) .ok_or_else(|| em("player gonee"))?; @@ -192,7 +201,10 @@ eprintln!("updates content iad={:?} player={:?} cl={:?} updates={:?}", Some((i,_)) => i, }; - UpdateReader { player, client, to_send, ami } + UpdateReader { + player, client, to_send, ami, + init_confirmation_send : iter::once(()), + } }; BufReader::with_capacity(UPDATE_READER_SIZE, content) }