Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by shriya · May 09, 2017 at 10:58 AM · issueserviceforloop

Fetching data from server hangs the game.

Hi,

I am using app42 services and fetching list of users in the beginning of the game but that takes too much time and hangs while adding that data to a list using for loop. May be the approach is not up to the mark. Any help would be great. Code snippet is below:

 public class GetAllUserCallBack : App42CallBack  
 {  
     public void OnSuccess(object response)  
     {   
         IList<User> user = (IList<User>) response;    
         //    App42Log.Console("userName is " + user.Count);  
         
         List <String> userNames=new List<string>();
         for(int i = 0; i < user.Count; i++)   
         {   
             userNames.Add(user[i].GetUserName() ) ;
         }
  
     }   
     public void OnException(Exception e)  
     {   
         App42Log.Console("Exception : " + e);  
     }   
 }
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by HarshadK · May 09, 2017 at 11:31 AM

One way to counter the delay is:

If you are not displaying or processing all users at once then you can fetch the limited number of users first using the paginated users list to have a few users available to display and then fetch the remaining users later on (preferably, in a background thread so that it would not hamper the gameplay). You can fetch this remaining list of users as paginated list itself to avoid long delays in fetching. This is something similar to how websites load items from list using AJAX when user reaches near the end of the list.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image shriya · May 10, 2017 at 05:58 AM 0
Share

i need to fetch all users at once as I need to compare with some other list

avatar image RobAnthem shriya · May 10, 2017 at 06:10 AM 0
Share

Something you need to learn to get around, when it comes to networking YOU CANNOT WAIT ON DATA. Seriously, it is a crippling thing to do. Find a way around it. Separate threads and events are helpful, create some sort of GUI element that pops up and says "Connecting Users..." so that your players are okay with waiting a moment.

Also, a very good practice to create a time-out limit for users who's data is not being collected in a timely manner. This will be annoying to users very rarely, and almost all games do it to prevent things like a bad connection ruining the game for all users.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

66 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

SyntaxError: missing ) after formal parameters 1 Answer

Issue With Spare Ammo In Reload Script 0 Answers

Mess collider issue 1 Answer

What can cause shadow slicing while moving camera? 1 Answer

Occlusion Culling issue (works like Frustum Culling) 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges