Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6878577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:44:28+00:00 2026-05-27T04:44:28+00:00

I’m making a turn based rpg game with some multiplayer functions using GAE. I

  • 0

I’m making a turn based rpg game with some multiplayer functions using GAE. I have a pvp lobby where players can view other players that are online. Players can also challenge each other in the lobby and start a fight. The actual fighting is not taking up that much resources. Whats taking up resources is the lobby. From my dashboard I can see that “datastore read operations” is what’s taking up most resources.

I’m fairly certain that the way I’m doing this is pretty stupid, I mean there just has to be a better way. Every player that is in the lobby pings the server every other second. Then the following happens:

  1. The server checks through a list of registered players to see if the name of the pinging player matches the name of the players in the list. That object is then used in (2) and (3).

  2. The server updates the time that the player pinged so that it (later) can return a list containing only players that have pinged the server in the last 10 seconds.

  3. The server checks if someone has challenged that player.

Here’s the code that tries to find the pinging player(that is, (1) above):

javax.jdo.Query query = pm.newQuery("SELECT FROM " + Player.class.getName());

        List<Player> players = new ArrayList<Player>();
        players = (List<Player>) query.execute();

        for(int i = 0; i < players.size(); i ++)
        {
            if(players.get(i).getName().equals(playerName))
            {
                //Found correct player!
                break;
            }
        }

When there are hundreds of registered players, finding a particular player once every other second for each player in the lobby seems like a real waste.

Question: Is there some better way of doing this? I’m thinking perhaps I’m fetching the calling player inefficiently?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T04:44:29+00:00Added an answer on May 27, 2026 at 4:44 am

    You’re iterating over every single registered player every time you try and find one. Since you’re doing a simple equality test, you should apply a filter to your query to return just the desired record. JDO queries, and how to add filters, are documented here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have thousands of HTML files to process using Groovy/Java and I need to
I'm making a simple page using Google Maps API 3. My first. One marker
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.