I'm using tokio-tungstenite for WebSocket connections, and I have a dispatch_global(event) function that should dispatch an event to every connection, the blocking method for this is
for mut conn in self.conns.iter_mut() {
conn.send(message.clone()).await?;
}
self.conns is a DashMap and conn is WebSocketStream which implements Sink, send is SinkExt's method from futures-rs, so I'm stuck here because whatever I do will give me lifetime errors
My general recommendation is that IO resources do not go in hash maps, and that you should have only one IO resource per task. Consider using the actor pattern for controlling your IO resource.