Introduction
When working with the PureWeb Reality streaming platform, particularly with custom web client, developers often encounter issues related to status messages and correct timing of sending messages between the game and web client.
A common problem is the failure to receive the "serviced" status, with the logging stopping at the "ready" state. This guide aims to provide practical solutions to ensure smooth communication between the game and the web client.
Status Messages in PureWeb Streaming
PureWeb's platform provides various status messages to indicate the connection and readiness states of the platform and the stream. These statuses are crucial for understanding the current state of the application and the streaming process. However, it is important to note that these status messages do not convey the readiness status of the game itself. This distinction is vital for troubleshooting.
Key Status Messages
- Ready: Indicates that the application is ready but does not guarantee that the game and web client are fully ready to communicate.
- Serviced: Indicates that the web client has successfully connected and is receiving service.
Timing Challenges in Message Communication
One of the most challenging aspects of using PureWeb Streaming is ensuring the correct timing of initial messages between the game and the web client. If either side sends a message before the other is ready, the message will essentially be lost. This timing issue is a common reason for not receiving the "serviced" status.
Example Scenarios
- Game Sends Message Prematurely: If the game sends a message before the stream has fully connected, the web client will not receive it, causing the status to remain at "ready."
- Web Client Sends Message Prematurely: Similarly, if the web client sends a message while the game is still loading assets or starting up, the game may not be ready to process it, leading to missed communication.
Practical Solution: Delaying Game Initialization
To address the timing issue, introducing a delay before the game starts sending messages can be an effective solution. This ensures that both the game and the web client are fully ready to communicate. Below is a sample implementation for Unity that demonstrates how to introduce a delay on startup.
Unity Code Example
public class GameManager : MonoBehaviour
{
public GameObject objectToLoad; // Assign your prefab here in the Inspector
void Start()
{
// Use a condition or a delay to control when to load your GameObject
Invoke("LoadObject", 5); // Call LoadObject method after 5 seconds
}
void LoadObject()
{
Instantiate(objectToLoad);
}
}
In this example, the Invoke
method is used to delay the loading of the game object by 5 seconds. This delay ensures that the game is ready before it attempts to send any messages to the web client.
Conclusion
Understanding the status messages and timing issues in PureWeb Streaming is crucial for ensuring smooth communication between the game and the web client. By recognizing the importance of synchronization and implementing practical solutions such as introducing delays, developers can prevent common issues like missing the "serviced" status. This guide serves as a resource for troubleshooting and resolving these issues, ensuring a more reliable streaming experience with PureWeb.