0

I'm new in App Engine. I want to create guess words game with App Engine. So, I need to create one instance of main channel thread that listen to answer from clients and sending response and new question every periode of time.

Illustration

Illustration

(1) The server thread send message to the clients

(2) Sleep for 10 seconds.

(3) Prepare new message and back to step (1)

I don't understand how to create such thread in App Engine Backend. All I know, if I need thread, I can create it in a Backend.

I don't completely understand about explaination in Google Developer that talk about Backend. So, please help me to figure it out about its concept.

I need help. How can I create a thread in Google App Engine Backend? What files (scripts and configurations) are needed to create that project? I need a view of directory listing about it. Please give me simple example that contain one frontend and one back

Ifan Iqbal
  • 3,053
  • 5
  • 28
  • 31
  • Maybe this helps:http://stackoverflow.com/questions/20816058/web-based-multiplayer-board-card-game-toolkit/20855422#20855422 – Jimmy Kane Jan 20 '14 at 09:16
  • 1
    Why does this need to be done in a thread? Why not with a normal request/response cycle? – Daniel Roseman Jan 20 '14 at 09:57
  • The server need to send message to all clients continuously in realtime. Request/response cycle does help me when server need to forward message from one client to another. – Ifan Iqbal Jan 20 '14 at 13:47

1 Answers1

2

OK as far as I understand it...

create a file bg_worker.yaml with the normal stuff for a module plus a handler for start and a handler for stop:

application: your-app 
module: bg_worker

handlers:
url: /_ah/start   
script: main.startWorker

url: /_ah/stop   
script: main.stopWorker

in main.startWorker start your bg thread:

_thread = BackgroundThread(target = work)

Once done you can start it by including the new yaml file in the update command,

appcfg -oauth2 update app.yaml bg-worker.yaml
Jumfer
  • 77
  • 8