Hello,
I have made a notification system (friend request, invite to game...) on a desktop game using unity as follows:
- Client sends a friend request using a cloud script function
- The function then fills in the SharedGroupData of the friend with the name of the player who sent it
The player receives the notification, but the way I am refreshing the notification list is by using the "Heartbeat" method, which is to request the data from the SharedGroupData every like 5 seconds or so.
But isn't this too costly to keep requesting data every few seconds? because I have other methods that does the same like the friends list that keeps refreshing in the same way.
This is working perfectly, and I know there is no push notifications for desktops, but is there a better solution than this?
Thank you
Answer by Brendan · Jul 22, 2016 at 05:25 PM
Yes, we'll be adding a publish/subscribe system in an upcoming release, at which point you'll want to move to that. For now, if you use a heartbeat model for this sort of thing, please don't query more often than about every 30 seconds (which is similar to the heartbeat period in PSN and XBL).
Alright I will stick to the 30 seconds heartbeat for now, but that means if someone invites his friend it will take up to 30 seconds before he receives the invite..
Can you please explain more of what the publish/subscribe system is? and how long is approximately the upcoming release for it? a month, a year?
Honestly, I can't see that being an issue for your players. The heartbeat time on Xbox Live is such that it can be up to 40 seconds before you get a presence update for friends, and I've never heard of that being an issue.
The pub/sub model is that an entity (client/server) will be able to subscribe to specific events from another entity. So you'll be able to specify PlayStream events that, when they occur, you'll receive a notification if you've subscribed with a listener. We'll have all the details at release, which is targeted for later this year.
Well I never noticed that a game invite would take up to 40 seconds to be sent to my friend, it always seemed instant, that's why I was asking. But if it like that then I am no better than Xbox live or PSN, 30 seconds it is!
And thank you for the info Brendan, I'm always bothering you :)
Can We call Cloud Scripts in Unity - void Update() for receiving a friend request ? 2 Answers
How to access the variables in the cloud script ? 1 Answer
How to access the variables of cloud scripts in Unity's C# script ? 0 Answers
ExecuteCloudScript Errors - 'ExecuteCloudScriptResult' does not contain a definition 0 Answers
Cloud Script Return Value Problem - Null Reference Error 1 Answer