Sign In Register

How can we help you today?

Start a new topic
Answered

Real Time database for social game?

I'm currently evaluating gamesparks. I need my database to be "real time" similar to what firebase offer. What I mean by this is that whenever a change occurs in the data, the data is automatically updated to every logged users currently looking at that data. For example, if someone would send a like to a post made by a user(imagine something similar to facebook), every users currently looking at the post would see the additional like on the post without having to spam refresh.

Would this be possible and economically possible with gamesparks?

From what I gathered by reading the documentation, the data doesn't automatically sync like firebase offer but I think I could achieve real time through the messaging system. So if someone sends a like then the system can sends a message to everyone reading the post to update the data. What I'm worried though is that this might use too much api calls? Since we are limited to 5k/MAU api calls, I'm not sure how much calls a user would use in a month through this method. Lets say I have a super popular post and everyone sends a like to it and someone happens to be looking at that post while everyone is liking it then I wouldn't be surprised to max out the 5k pretty quickly

Please let me know what you think; would be great to have an answer from the team.


Best Answer

Hi Joe,


It's completely possible to this, however it will be complex and yes it will involve a lot of API calls. You'll need an API call for:


-Every time the client loads a post.

-Every time a client likes/interacts with a post. 


Since GameSparks employs a socket system these updates will be 'realtime', the moment the update is registered on the backend it can be sent straight back to clients 'monitoring' this change. It will be a lot of GameSparks messages management. 


By theory, every time a user loads a post (In their feed or is focused on it/opens it) then they become subscribed/monitor this post. A post can be an entry in a collection, lets call this collection 'Posts', Whenever a player accesses a post, then we save that player's ID in this entry.
The entry will look something like this:

{

 "_id": {

  "$oid": "56aa17f9e4b025c78f51c47b"

 },

 "comments": [{"userID":"56aa17f9e4b025c78f51c47b","Message":"Woooow awesome!"}]

 "author": "Player223",

 "likes": "3",

 "timePosted": "Medium",

 "playersSubbed":["56aa17f9e4b025c78f51c47b","56bb17f9h8b025c78f51c47b"]

}


As players load or lose this post, they're status of being in the 'playersSubbed' array will change.


Now anytime a user makes a change to this post (liking, deleting, interacting) then the backend will find the ID of this post, do a bulk job to aquire those players subscribed through the array of string 'playersSubbed' and loop through them and send them a message informing them it's been changed, whats changed and ensures the device registers and adapts to this change. 


Hope this sheds more light on your application needs, this of course is only one way of doing it, there are many ways.


Cheers,

Omar

1 Comment

Answer

Hi Joe,


It's completely possible to this, however it will be complex and yes it will involve a lot of API calls. You'll need an API call for:


-Every time the client loads a post.

-Every time a client likes/interacts with a post. 


Since GameSparks employs a socket system these updates will be 'realtime', the moment the update is registered on the backend it can be sent straight back to clients 'monitoring' this change. It will be a lot of GameSparks messages management. 


By theory, every time a user loads a post (In their feed or is focused on it/opens it) then they become subscribed/monitor this post. A post can be an entry in a collection, lets call this collection 'Posts', Whenever a player accesses a post, then we save that player's ID in this entry.
The entry will look something like this:

{

 "_id": {

  "$oid": "56aa17f9e4b025c78f51c47b"

 },

 "comments": [{"userID":"56aa17f9e4b025c78f51c47b","Message":"Woooow awesome!"}]

 "author": "Player223",

 "likes": "3",

 "timePosted": "Medium",

 "playersSubbed":["56aa17f9e4b025c78f51c47b","56bb17f9h8b025c78f51c47b"]

}


As players load or lose this post, they're status of being in the 'playersSubbed' array will change.


Now anytime a user makes a change to this post (liking, deleting, interacting) then the backend will find the ID of this post, do a bulk job to aquire those players subscribed through the array of string 'playersSubbed' and loop through them and send them a message informing them it's been changed, whats changed and ensures the device registers and adapts to this change. 


Hope this sheds more light on your application needs, this of course is only one way of doing it, there are many ways.


Cheers,

Omar


1 person likes this
Login to post a comment