Poll or Subscribe - ajuna-network/Polkadot.Unity.SDK GitHub Wiki

The Substrate .NET API Stack currently supports the following architectures.

image Note: There is an outdated Demos repository, showing all kinds of possibilities to get storage, with the SDK, please only use it as an indication.

Polling

Polling is a method where the game client regularly requests data updates from the server to maintain storage consistency. In the context of the Substrate .NET API Stack, polling is often preferred for major game or app development due to its simplicity and reliability. It allows for a more controlled and predictable update mechanism, reducing the risk of inconsistencies in game state. Polling can be easily managed by a dedicated manager within the game architecture, ensuring the game remains in sync with on-chain storage without tightly coupling game logic to storage events.

Subscribing

Subscribing involves setting up listeners that automatically receive updates when specific changes occur in the storage. This method is more event-driven and can lead to tighter coupling between game events and storage states. While it can get complicated when subscribing to various storage changes, certain subscriptions, like transaction state updates or account balance changes, are crucial for real-time player feedback and game dynamics. Subscriptions can provide immediate updates, enhancing the player's experience by reflecting real-time changes in the game world.

Comparing Polling and Subscribing

Polling and subscribing offer different advantages for game development. Polling is simpler to implement and manage, making it suitable for maintaining a consistent game state across all players. It's less prone to errors and complexities associated with event-driven architectures. On the other hand, subscribing provides real-time updates, essential for dynamic game features and immediate player feedback. However, it requires more intricate handling of storage state changes and can lead to complex game architectures. The choice between polling and subscribing depends on the specific needs of the game, such as the importance of real-time updates versus the simplicity and reliability of state management.

Conclusion

In game development using the Substrate .NET API Stack, both polling and subscribing have their place. Polling is generally preferred for its simplicity and ease of maintaining consistent storage states, especially in large-scale games. Subscribing, while more complex, is invaluable for specific features that require immediate updates. Developers must weigh the benefits and challenges of each method to choose the most appropriate approach for their game's architecture and player experience requirements.