1. beyzend
  2. projectace3_gae_app


beyzend  committed 56cedcf Draft

-update server-side service code. This is to faciliate upcoming game server game state code.
-Services has been changed to enable bulk updates from the client-side.

  • Participants
  • Parent commits 039902f
  • Branches default

Comments (0)

Files changed (4)

File app.yaml

View file
 # Static: downloads
 - url: /downloads
   static_dir: downloads
+# Test /_ah/start script for simulating backends on the dev. machines. Having backends enabled on dev. machines is too slow.
+#- url: /test/_ah/start
+#  script: /gameserver/startserver.py
 # Examples, each in the examples folder/name_of_example.
 # Note: All examples share the same templates, flash, and js folders. 
 - url: /.*
   script: main.py
 #instead of CGI based handler use a WSGI based. See python 2.7 GAE migration guide. NVM. Need to upgrade GAE on dev machine first.
 #- url: /.*
 #  script: main.application

File gameserver/GameServer.py

View file
-def getCountService(idx):
-    if(idx >= maxMobs):
-        idx = maxMobs - 1 
-    return [idx, mobs[idx]]
+def getCountService(idrange):
+    """
+    idrange specifies a range of ids.
+    WARNING: No range checks!!!
+    Why? We're making a game here. We assume whoever is calling this knows what they're doing.
+    """
+    return mobs[idrange[0]:idrange[1]]

File queue.yaml

View file
 - name: default
-  rate: 1/s
+  rate: 0.5/s
+  max_concurrent_requests: 1

File services/mob.py

View file
 from google.appengine.api import backends
 from google.appengine.api import urlfetch
+import time 
 XRANGE=32*32 #there are 32 tiles in the first test map
-def mob(id):
+def mob(idrange):
     url = '%s/' % (backends.get_url('gameserver'))
     gateway = RemotingService(url+"gateway")
     service = gateway.getService('gameserver.gameserver')
-    retArray = service(id)
+    retArray = service(idrange)
     return retArray
     #assume currentPos is a tuple representing a vector2 where in the order is x,y
     #assume a Poisson variable
     #return {"id":id, "randtime":-log(1.0 - random.random()) / MEAN_TIME}
-    return [0, 0]