Skip to content

Commit

Permalink
same trick for other subscribers
Browse files Browse the repository at this point in the history
  • Loading branch information
notV4l committed Jun 10, 2024
1 parent 29a3a7e commit f8f67c3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
6 changes: 3 additions & 3 deletions crates/torii/grpc/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ impl WorldClient {
.map_err(Error::Grpc)
.map(|res| res.into_inner())?;

Ok(EntityUpdateStreaming(stream.map_ok(Box::new(|res| {
let entity = res.entity.expect("entity must exist");
entity.try_into().expect("must able to serialize")
Ok(EntityUpdateStreaming(stream.map_ok(Box::new(|res| match res.entity {
Some(entity) => entity.try_into().expect("must able to serialize"),
None => Entity { hashed_keys: FieldElement::ZERO, models: vec![] },
}))))
}

Expand Down
11 changes: 11 additions & 0 deletions crates/torii/grpc/src/server/subscriptions/entity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use torii_core::types::Entity;
use tracing::{error, trace};

use crate::proto;
use crate::proto::world::SubscribeEntityResponse;

pub(crate) const LOG_TARGET: &str = "torii::grpc::server::subscriptions::entity";

Expand Down Expand Up @@ -48,6 +49,16 @@ impl EntityManager {
EntitiesSubscriber { hashed_keys: hashed_keys.iter().cloned().collect(), sender },
);

// unlock issue with firefox/safari
// send empty model update to unlock browsers ...
let subscribers = self.subscribers.write().await;
let _ = subscribers
.get(&id)
.unwrap()
.sender
.send(Ok(SubscribeEntityResponse { entity: None }))
.await;

Ok(receiver)
}

Expand Down
11 changes: 11 additions & 0 deletions crates/torii/grpc/src/server/subscriptions/event_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use torii_core::types::EventMessage;
use tracing::{error, trace};

use crate::proto;
use crate::proto::world::SubscribeEntityResponse;

pub(crate) const LOG_TARGET: &str = "torii::grpc::server::subscriptions::event_message";
pub struct EventMessagesSubscriber {
Expand Down Expand Up @@ -47,6 +48,16 @@ impl EventMessageManager {
EventMessagesSubscriber { hashed_keys: hashed_keys.iter().cloned().collect(), sender },
);

// unlock issue with firefox/safari
// send empty model update to unlock browsers ...
let subscribers = self.subscribers.write().await;
let _ = subscribers
.get(&id)
.unwrap()
.sender
.send(Ok(SubscribeEntityResponse { entity: None }))
.await;

Ok(receiver)
}

Expand Down

0 comments on commit f8f67c3

Please sign in to comment.