Online Users Score

0 votes


I am developing a game similar to Tic-Tac-To.

I used Facebook as my user base so I used "Storage Service" to store each Facebook users.

What I want is when a user is online he/she can see other login users(Facebook photo, name, scores,stats..) and then he/she can invite any other online user to play with.



1. What is the best way to link the Appwarp Online Users with the Storage Service efficiently in order to retrieve their score/photo/name?



a) Update the JSON of the Storage Service each time a user login or logout so that I can effeciently query for online users. But that will cause problem when user don't logout properly(Internet connection down, App crash...etc.).

b) Get list of Online users with warpClient.getOnlineUsers() and then use QueryBuilder to build compound query against the Storage Service. BUT HOW ABOUT PERFORMANCE ISSUE if I have 200,000 users and around 3000 online users???


ArrayList<String> usernames = warpClient.getOnlineUsers() ;

for(int i=0; i<usernames.size(); i++){

Query q ="UserName",score.getUserName(), Operator.EQUALS);



// build a query for user profiles

Query finalQuery = queries.get(0);

for(int i=1; i<queries.size(); i++){

Query q = queries.get(i);

finalQuery = QueryBuilder.compoundOperator(q, Operator.OR, finalQuery);


Storage storageObj = storageService.findDocumentsByQuery(Constants.USER_DB_NAME, Constants.USER_PROFILE_COLLECTION, finalQuery);

ArrayList<Storage.JSONDocument> list = storageObj.getJsonDocList();


Your suggestion is much appreciated


asked Dec 26, 2014 in AppWarp by chamroeun (25 points)
edited Dec 27, 2014 by chamroeun

1 Answer

0 votes
Best answer
Hello Chamroeun,

Thanks for sharing all the details with us.

Instead of created multiples of queries, you can maintain a key in user document for online status & fetch the document based on that key & display all the information related to that user. Which make your app more responsive & fit for your use case. About updating the user document, you need to manage it on client side that user is online or not, if user is online update the json document respectively.

Let us know if it helps.

Himanshu Sharma
answered Dec 28, 2014 by hs00105 (2,005 points)
selected Dec 29, 2014 by chamroeun
Thanks for your help.

What do you mean by key here? You mean document id or a document field?

Yes, i will query the docs and use QueryBuilder with compound operator OR(Please take a peek at my code posted) but WHAT IF I have 200,000 users(profiles)? Will it severely affect the performance?

Regarding performance, you can query those users in the chunk of 100. Like if you get your online users from AppWarp then you have to divide those users in chunks of 100 and then query this list of users from storage service to get extra information of that user. About the key which you want to manage for the online user. You can apply both ways one you which you have stated above also effective. Let me know if it helps.
That's a great solution. Many thanks;
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on