chiark / gitweb /
init confirmation send
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 4 Jul 2020 18:37:28 +0000 (19:37 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 4 Jul 2020 18:40:20 +0000 (19:40 +0100)
src/sse.rs

index defda9451ff20cc82cac65765bff17ce55768b54..267c284c263fb81173556054043f8ca566fd6cde 100644 (file)
@@ -39,6 +39,7 @@ impl StableIndexOffset for UpdateId {
 struct UpdateReader {
   player : PlayerId,
   client : ClientId,
+  init_confirmation_send : iter::Once<()>,
   to_send : UpdateId,
   ami : Arc<Mutex<Instance>>,
 }
@@ -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)
 }