Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[trick] to unlock toriiClient with safari/firefox #2038

Merged
merged 4 commits into from
Jun 13, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
same trick for other subscribers
notV4l authored and Larkooo committed Jun 13, 2024
commit 6722c0d19dcc0c8246e65228b534fe3652d228b4
6 changes: 3 additions & 3 deletions crates/torii/grpc/src/client.rs
Original file line number Diff line number Diff line change
@@ -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![] },
}))))
}

11 changes: 11 additions & 0 deletions crates/torii/grpc/src/server/subscriptions/entity.rs
Original file line number Diff line number Diff line change
@@ -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";

@@ -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)
}

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
@@ -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 {
@@ -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)
}