Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

You can now restart the gameState with a POST request to 1730 #6

Open
sdunham opened this issue Dec 4, 2012 · 11 comments
Open

You can now restart the gameState with a POST request to 1730 #6

sdunham opened this issue Dec 4, 2012 · 11 comments

Comments

@sdunham
Copy link
Member

sdunham commented Dec 4, 2012

I'll update the API documentation soon, but you can reset the gameState by POSTing in the following manner:

http://puppetmaster.pugetsound.edu:1730/gameState.json?restartGame=true

If you're not the Game Engine, you probably shouldn't be doing this...

@d-bahr
Copy link

d-bahr commented Dec 5, 2012

When I try to post the request, I get a '400 Bad Request' error. I'm 95% sure that my code should work :D

@iameli
Copy link

iameli commented Dec 5, 2012

Try now.

@d-bahr
Copy link

d-bahr commented Dec 5, 2012

Still happening. I'm able to post phone scores though, which have roughly the same format, so I'm not sure why that works and this doesn't...

@sdunham
Copy link
Member Author

sdunham commented Dec 5, 2012

Sorry about that... Seemed to be working when I tested it in the browser,
but it looks like it needs some tweaking. I'll fiddle with it tonight and
get back to you.

On Tue, Dec 4, 2012 at 6:17 PM, Daniel Bahr [email protected]:

Still happening. I'm able to post phone scores though, which have roughly
the same format, so I'm not sure why that works and this doesn't...


Reply to this email directly or view it on GitHubhttps://github.com//issues/6#issuecomment-11025482.

@sdunham
Copy link
Member Author

sdunham commented Dec 5, 2012

I just successfully retested by sending an ajax call to
http://puppetmaster.pugetsound.edu:1730/gameState.json?restartGame=true

Is "Bad Request" the exact error text you're getting back? There are a
couple places in the code where we catch errors and respond with a 400
code, and knowing the exact message will help me figure out which one your
request is getting caught in.

It's a long shot, but are you sending more than just the restartGame
variable with your POST request? If you were sending some phone score data
as well, I can see where the issue might be.

On Tue, Dec 4, 2012 at 6:36 PM, Scott Dunham [email protected] wrote:

Sorry about that... Seemed to be working when I tested it in the browser,
but it looks like it needs some tweaking. I'll fiddle with it tonight and
get back to you.

On Tue, Dec 4, 2012 at 6:17 PM, Daniel Bahr [email protected]:

Still happening. I'm able to post phone scores though, which have roughly
the same format, so I'm not sure why that works and this doesn't...


Reply to this email directly or view it on GitHubhttps://github.com//issues/6#issuecomment-11025482.

@iameli
Copy link

iameli commented Dec 5, 2012

It should be parsing the request and responding with a 204 "No Content"
reply--the 2XX code affirms success but there's no data with which we can
logically reply.

Maybe it's working but your code is seeing no content and responding with
an error?

On Tue, Dec 4, 2012 at 8:45 PM, sdunham [email protected] wrote:

I just successfully retested by sending an ajax call to
http://puppetmaster.pugetsound.edu:1730/gameState.json?restartGame=true

Is "Bad Request" the exact error text you're getting back? There are a
couple places in the code where we catch errors and respond with a 400
code, and knowing the exact message will help me figure out which one your
request is getting caught in.

It's a long shot, but are you sending more than just the restartGame
variable with your POST request? If you were sending some phone score data
as well, I can see where the issue might be.

On Tue, Dec 4, 2012 at 6:36 PM, Scott Dunham [email protected]
wrote:

Sorry about that... Seemed to be working when I tested it in the
browser,
but it looks like it needs some tweaking. I'll fiddle with it tonight
and
get back to you.

On Tue, Dec 4, 2012 at 6:17 PM, Daniel Bahr [email protected]:

Still happening. I'm able to post phone scores though, which have
roughly
the same format, so I'm not sure why that works and this doesn't...


Reply to this email directly or view it on GitHub<
https://github.com/UPS-CS240-F12/main_trunk/issues/6#issuecomment-11025482>.


Reply to this email directly or view it on GitHubhttps://github.com//issues/6#issuecomment-11029495.

@d-bahr
Copy link

d-bahr commented Dec 5, 2012

I just double-checked my code and I'm not sure there's anything wrong. I will try a couple things tomorrow when I'm on campus again.

@sdunham
Copy link
Member Author

sdunham commented Dec 5, 2012

In anticipation of getting this issue figured out, I want to make one small
tweak to this part of the API which I think should clear up a few
unresolved issues.

There are now essentially 2 versions of this call that you can make, and
I'm wondering if you can make them in 2 different places in your code:

  1. Reset the JSON, but don't log scores for the leaderboard
    This will be the same POST request that you're attempting to make now (
    http://puppetmaster.pugetsound.edu:1730/gameState.json?restartGame=true).
    It will reinitialize the JSON, and should be called right before you
    start a new game (before you set gameRunning to true).
  2. Reset the JSON and log scores for the leaderboard
    For this call, you will add a new parameter to your POST request (
    http://puppetmaster.pugetsound.edu:1730/gameState.json?restartGame=true&logScores=true).
    This call will reinitialize the JSON and log high scores in our
    leaderboard. You should call this when a game has finished, and after you
    have updated player/phone scores to their final score.

Let us know if you have any issues with any of this.

On Tue, Dec 4, 2012 at 10:47 PM, Daniel Bahr [email protected]:

I just double-checked my code and I'm not sure there's anything wrong. I
will try a couple things tomorrow when I'm on campus again.


Reply to this email directly or view it on GitHubhttps://github.com//issues/6#issuecomment-11031399.

@d-bahr
Copy link

d-bahr commented Dec 7, 2012

I'm still unable to get either of them working. And now that I'm thinking about it, I'm not even sure that updating phone scores is working, because we haven't been able to test with the phone group.

I've spent several hours on this and I still have no idea why it's not working =\

@sdunham
Copy link
Member Author

sdunham commented Dec 7, 2012

Well, that's frustrating... Sorry for all the issues. Could you point me to where in your code you're making the restartGame calls? You could try POSTing phone scores to the simulator, if you want to test out that functionality before your next meeting with the phone group. I'd be very curious to hear if that fails as well.

This is probably self-explanatory, but just to make sure we've covered all possible sources of this issue:

These calls are different from the standard GET/POST JSON calls, in that they expect URL parameters which we parse on the server side (and don't include any JSON data). The fact that you can successfully POST gameState JSON, but are unable to POST using URL parameters makes me wonder if the required parameters aren't being tacked on to the request URL somehow...

@d-bahr
Copy link

d-bahr commented Dec 9, 2012

Got it working. I pushed the changes in the most recent commit to the Game Engine's repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants