Skip to content

Commit

Permalink
fix initial
Browse files Browse the repository at this point in the history
  • Loading branch information
v3g42 committed Aug 20, 2024
1 parent 587c00e commit ca4cc42
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/broadcast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,18 @@ impl BroadcastGroup {
};
let stream_task = {
let awareness = self.awareness().clone();

tokio::spawn(async move {
let payload = {
let mut encoder = EncoderV1::new();
let awareness = awareness.read().await;
protocol.start(&awareness, &mut encoder)?;
encoder.to_vec()
};
if !payload.is_empty() {
let mut s = sink.lock().await;
s.send(payload).await.map_err(|e| Error::Other(e.into()))?;
}
while let Some(res) = stream.next().await {
let msg = Message::decode_v1(&res.map_err(|e| Error::Other(Box::new(e)))?)?;
let reply = Self::handle_msg(&protocol, &awareness, msg).await?;
Expand Down

0 comments on commit ca4cc42

Please sign in to comment.