You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When they connect to my SSE stream i'm adding them to a hashmap, upon disconnection i would like to remove them, but i don't really have the connection.
I'm using a BearerAuth security scheme to tell which user is connecting.
#[oai(path = "/resources.stream", method = "get", tag = ApiTags::ResourceEvents)]
async fn index(
&self,
user: BearerAuth,
client: Data<&Arc<redis::Client>>,
app_state: Data<&Arc<AppState>>,
) -> EventStream<BoxStream<'static, ResourceEvent>> {
let sender: broadcast::Sender<ResourceEvent> = broadcast::Sender::new(100);
let user_rooms = vec![user.payload().sub];
let mut store = app_state.resource_event_rooms.lock().await;
for room in user_rooms {
store.entry(room).or_insert(vec![]).push(sender.clone());
}
// I would like to remove the user from the above map when they disconnect.
EventStream::new(
async_stream::stream! {
for i in 0.. {
tokio::time::sleep(Duration::from_secs(1)).await;
yield Event { value: i };
}
}
.boxed(),
)
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
When they connect to my SSE stream i'm adding them to a hashmap, upon disconnection i would like to remove them, but i don't really have the connection.
I'm using a BearerAuth security scheme to tell which user is connecting.
Beta Was this translation helpful? Give feedback.
All reactions