kapa.ai
NNormal
•Created by DC on 1/21/2025 in #🤝ask-a-question
catch and handle realtime errors?
It's worth noting that while this method allows you to detect and respond to connection errors, it doesn't provide detailed error codes or exceptions. The error handling in Normcore is designed to be more event-driven rather than exception-based.
For more information on the Room class and its events, you can refer to the Room reference documentation.
Remember to unsubscribe from the event when your component is destroyed to prevent memory leaks:
This approach should allow you to catch and handle Realtime connection errors in a more controlled manner.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
6 replies
NNormal
•Created by DC on 1/21/2025 in #🤝ask-a-question
catch and handle realtime errors?
----------------------
To handle Realtime connection errors in Normcore, you can use the
connectionStateChanged
event provided by the Room class. This event allows you to monitor changes in the connection state, including error states. Here's how you can implement error handling:
1. First, subscribe to the connectionStateChanged
event on the Room object.
2. In the event handler, check for error states and handle them accordingly.
Here's an example of how you can implement this:
In this example, we're subscribing to the connectionStateChanged
event and checking for the Error
state. When an error occurs, you can handle it appropriately, such as logging the error, displaying a message to the user, or attempting to reconnect.6 replies
NNormal
•Created by DC on 1/21/2025 in #🤝ask-a-question
catch and handle realtime errors?
Hi @DC. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
6 replies
NNormal
•Created by JimJamesJimJim on 1/20/2025 in #🤝ask-a-question
ownerIDSelfDidChange question
5 replies
NNormal
•Created by JimJamesJimJim on 1/20/2025 in #🤝ask-a-question
ownerIDSelfDidChange question
----------------------
Yes, the
ownerIDSelfDidChange
event fires when the ownership of a RealtimeView changes, including when it becomes unowned. When no one owns the RealtimeView, the int
parameter (representing the new owner ID) will be -1.
This behavior is consistent across RealtimeView, RealtimeComponent, and RealtimeModel, as they all have similar ownership properties. According to the RealtimeModel reference:
The client ID of the model owner. If the model is unowned, this returns -1.So, when the RealtimeView becomes unowned, the
ownerIDSelfDidChange
event will fire with -1 as the new owner ID.
It's worth noting that you can also check the ownership status using the isUnownedSelf
property, which will be true
when the RealtimeView is not owned by any client, as mentioned in the RealtimeView reference:
isUnownedSelf: True if the component is not owned by any client.This property can be useful in conjunction with the
ownerIDSelfDidChange
event to manage ownership-related logic in your application.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------5 replies
NNormal
•Created by JimJamesJimJim on 1/20/2025 in #🤝ask-a-question
ownerIDSelfDidChange question
Hi @JimJamesJimJim. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
5 replies
NNormal
•Created by beeeen on 1/17/2025 in #🤝ask-a-question
Any support for DOTS/ECS entities?
9 replies
NNormal
•Created by beeeen on 1/17/2025 in #🤝ask-a-question
Any support for DOTS/ECS entities?
----------------------
Based on the provided knowledge sources, there is no specific information about Normcore's support for Unity's DOTS (Data-Oriented Technology Stack) or ECS (Entity Component System) entities. The documentation primarily focuses on Normcore's own architecture and components, which appear to be designed around traditional Unity GameObjects and MonoBehaviours.
Normcore's architecture is built on concepts like RealtimeComponents and RealtimeModels, which are closely tied to Unity's standard component-based system. The Realtime API and Room + Datastore API don't mention any integration with DOTS or ECS.
Regarding the possibility of creating a "bridge" between DOTS and Normcore's API, it's difficult to provide a definitive answer based on the available information. Such an integration would likely require significant custom development, as Normcore's synchronization system is designed around its own component and model structure.
For the most up-to-date and accurate information on potential DOTS/ECS support or integration possibilities, I recommend reaching out directly to the Normcore team or consulting their community resources. As mentioned in one of the documents, you can contact them or join their Discord community for more specific inquiries about future support or integration possibilities.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
9 replies
NNormal
•Created by beeeen on 1/17/2025 in #🤝ask-a-question
Any support for DOTS/ECS entities?
Hi @beeeen. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
9 replies
NNormal
•Created by fgamez1020 on 1/17/2025 in #🤝ask-a-question
User disconnection
----------------------
To detect when a user disconnects from a room in NormalVR, you can use the
RealtimeAvatarManager
component. This component provides events that notify you when avatars (representing users) are created or destroyed in the room. Specifically, you can use the avatarDestroyed
event to detect when a user disconnects.
Here's how you can implement this:
In this code, we subscribe to the avatarDestroyed
event of the RealtimeAvatarManager
. When a user disconnects, their avatar is destroyed, triggering this event. The AvatarDestroyed
method will be called, allowing you to handle the disconnection.
Remember to attach this script to the same GameObject that has the RealtimeAvatarManager
component.
It's worth noting that this method detects user disconnections indirectly through avatar destruction. According to the documentation, when a client crashes or their connection is dropped suddenly, the server will disconnect them after five seconds. Any models they own that are tagged with destroyWhenOwnerLeaves
will be automatically destroyed.
Realtime > Xr > Avatars
Architecture > Common Questions
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------4 replies
NNormal
•Created by fgamez1020 on 1/17/2025 in #🤝ask-a-question
User disconnection
Hi @fgamez1020. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
4 replies
NNormal
•Created by DC on 1/16/2025 in #🤝ask-a-question
is there a way to count the connections to the room without using the Avatar Manager
11 replies
NNormal
•Created by DC on 1/16/2025 in #🤝ask-a-question
is there a way to count the connections to the room without using the Avatar Manager
- Realtime
- Room
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
11 replies
NNormal
•Created by DC on 1/16/2025 in #🤝ask-a-question
is there a way to count the connections to the room without using the Avatar Manager
----------------------
Yes, there is a way to count the connections to a room without using the Avatar Manager in Normcore. You can use the
Realtime
component to get this information. Here's how you can do it:
1. First, you need to access the Room
object from your Realtime
instance.
2. The Room
class has a property called clientID
which represents the current client's ID.
3. You can use the datastore
property of the Room
to get all the client IDs connected to the room.
Here's a simple example of how you might implement this:
This approach uses the Realtime
and Room
classes, which are core components of Normcore, without relying on the Avatar Manager.
Remember that this method will count all connected clients, including those that might not have instantiated an avatar. If you need to track specific types of connections (e.g., only players with avatars), you might need to implement additional logic.
For more information on the Realtime
and Room
classes, you can refer to the Normcore documentation:11 replies
NNormal
•Created by DC on 1/16/2025 in #🤝ask-a-question
is there a way to count the connections to the room without using the Avatar Manager
Hi @DC. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
11 replies
NNormal
•Created by JimJamesJimJim on 1/15/2025 in #🤝ask-a-question
Best practices for requesting ownership of RealtimeView and needing to execute logic based on that
10 replies
NNormal
•Created by JimJamesJimJim on 1/15/2025 in #🤝ask-a-question
Best practices for requesting ownership of RealtimeView and needing to execute logic based on that
private void DoStuff()
{
// Your logic here
}
``
This approach has several advantages:
1. It uses the
ownerIDSelfDidChange event, which is fired when ownership changes, ensuring your logic runs at the right time.
2. It implements a timeout mechanism to handle cases where the ownership request might fail.
3. It properly cleans up the event listener to prevent memory leaks.
Remember, as mentioned in the [Normcore documentation](<https://docs.normcore.io/room/ownership-and-lifetime-flags#requesting-ownership-of-a-realtimeview>), a
RequestOwnership()` call is only rejected if the RealtimeView or a parent RealtimeView is owned by a different client. In most cases, your ownership request should succeed quickly.
By following these best practices, you can ensure that your logic executes correctly after ownership is confirmed, while also handling potential edge cases where ownership requests might fail or time out.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------10 replies
NNormal
•Created by JimJamesJimJim on 1/15/2025 in #🤝ask-a-question
Best practices for requesting ownership of RealtimeView and needing to execute logic based on that
----------------------
You're correct in identifying a potential issue with the code you've provided. The ownership request in Normcore is indeed asynchronous, and there's a better way to handle this scenario. Let's look at the best practices for requesting ownership and executing logic based on that.
According to the Normcore documentation on Ownership, when you call
RequestOwnership()
, Normcore assumes the call will succeed and allows you to use the object immediately. However, it's still a good practice to wait for the ownership change to be confirmed before executing critical logic.
Here's a better approach:
1. Use the ownerIDSelfDidChange
event to execute logic after ownership changes.
2. Implement a timeout mechanism to handle cases where ownership request might fail.
Here's an example of how you could implement this:
```csharp
private void RequestOwnershipAndExecuteLogic(RealtimeView rv)
{
// Set up a listener for ownership change
rv.ownerIDSelfDidChange += OnOwnershipChanged;
// Request ownership
rv.RequestOwnershipOfSelfAndChildren();
// Set up a timeout coroutine
StartCoroutine(OwnershipTimeout(rv, 5f)); // 5 second timeout
}
private void OnOwnershipChanged(RealtimeView rv, int previousOwnerID)
{
if (rv.isOwnedLocallySelf)
{
// Ownership confirmed, do stuff
DoStuff();
// Remove the listener
rv.ownerIDSelfDidChange -= OnOwnershipChanged;
}
}
private IEnumerator OwnershipTimeout(RealtimeView rv, float timeout)
{
yield return new WaitForSeconds(timeout);
if (!rv.isOwnedLocallySelf)
{
Debug.LogWarning("Ownership request timed out");
// Handle the timeout case
rv.ownerIDSelfDidChange -= OnOwnershipChanged;
}
}10 replies