I have had no issues with this at all.
Since you are clearly using Tier 2 (as I do), you might not be aware of the issues about calling agk::Sync() anywhere but as the last thing in the app::Loop() method.
Unlike Tier 1, the Sync() call does NOT cause all the user/external events to happen. In Tier 2 it only updates physics and the display. Any user inputs (keyboard, mouse, touch, etc.) are caught and handled at the end (or beginning, not sure) of the app::Loop() method. And I suspect that the HTTP functions are the same.
Unfortunately, in Tier 2, you basically have to set up a series of state engines (depending on how you do stuff).
There are several places in my WIP that require communication with my web server. And, using pseudo code, it works something like this:
// inside app::Loop()
switch (app_state)
{
case _IN_GAME_:
switch (mainProcessingLoop())
{
case _GAME_OVER_:
<exit procedure>
break;
case _GAME_ON_:
<update physics with desired time step>
break;
}
break;
case _IN_INITIALISATION_:
if (initialiseTheGame()) <had an error, handle it>
else app_state = _IN_GAME_;
break;
}
// in the mainProcessingLoop
switch (game_state)
{
case _PLAYING_:
<do playing stuff>
break;
case _GO_TO_MENU_:
<create menu display>
game_state = _SHOWING_MENU_;
break;
case _SHOWING_MENU_:
<do menu stuff, some option will set game_state to _SUBMIT_SCORES_>
break;
case _SUBMIT_SCORES_:
// initialise HTTP connect, iHttp is a global
iHttp = agk::CreateHTTPConnection();
// check connection
if (iHttp < 1) <error handling>
// set the host, sUrl is global
i_ret = agk::SetHTTPHost(iHttp, sUrl.c_str(), 0);
// check connection
if (i_ret < 0) <error handling>
// send the request
i_ret = agk::SendHTTPRequestASync(
iHttp,
sFile.c_str(),
sPostData.c_str() );
// check connection
if (i_ret < 0) <error handling>
// set up for possible timeout
max_time = agk::Timer() + 60.0f;
// okay, next step
game_state = _WAIT_FOR_SCORE_RETURN_;
break;
case _WAIT_FOR_SCORE_RETURN_:
// get time
curr_time = agk:Timer();
// check for response
resp = agk::GetHTTPResponseReady(iHttp);
// check for timeout
if ((resp == 0) && (curr_time > max_time)) <timeout error, changes game_state and breaks>
// did we get something
if (resp)
{
// get response
sReturn = agk::GetHTTPResponse(iHttp);
// close the connection
agk::DeleteHTTPConnection(iHttp);
// go to next step
game_state = _PROCESS_HTTP_STUFF_;
}
break;
case _PROCESS_HTTP_STUFF_:
<do something with it>
break;
}
Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master