Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Android HTML issues

Author
Message
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 5th Dec 2012 19:45
Hello. I have been trying to get on-line scores working using Daniel's on-line high score kit. On PC and Netbook, I have it working seemingly okay. On android however, it seems to hang some or mainly all of the time.
I have seen a few peoples releasing titles with an online score on android and wonder if anyone has an idea why I cannot get my android device to co-operate, as it obviously must work (unless there are any issues with 1076 I am using).
Here is the code from the online high score kit. It works great on PC but on android it hangs on the waiting for response at the start. It does send a score, so must have connected, but just sits there as if stuck.


I am wondering what difference there is between the SendHTTPRequestASync and SendHTTPRequest commands. There isn't much difference in the description, but it sounds like it may work better using async than the standard request command. Do you have any suggestions as to what I can try? Has anyone had this problem themselves and managed to solve it?

fog
20
Years of Service
User Offline
Joined: 5th Oct 2003
Location: Newcastle, England
Posted: 5th Dec 2012 20:30
Can't test as I don't have AppGameKit Basic installed, but is that Sync in the main loop recognised? The extra spaces might mean it gets ignored.

That would explain why it looks like it's working, but the screen just isn't updating to reflect that.

DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 5th Dec 2012 21:07
It works fine on PC like that or without the spaces. Makes no difference on the android though. If only it was that simple Cheers for the look over though!

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 5th Dec 2012 21:40
Android tends to be a little twitchy about case sensitivity. Could it be something is not quite right in that way?


this.mess = abs(sin(times#))
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 5th Dec 2012 22:14
Quote: "difference between SendHTTPRequestASync and SendHTTPRequest commands"

SendHTTPRequest sends the request and waits for the response and returns it when done.

SendHTTPRequestASync sends the request and DOES NOT wait for response. You need to use GetHTTPResponseReady to tell when it is done and then use GetHTTPResponse to get the response.

The use of GetHTTPResponseReady in a loop before you ever send any request. That is what looks like the probable problem. I'm surprised it works on the PC.

What, if anything, displays on your Android device?

I had no trouble doing http stuff with my Androids. But I was doing it a bit different than the code you show. And now I'm doing it in Tier 2 (and am much happier).

Cheers,
Ancient Lady
AGK Community Tester
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 5th Dec 2012 22:42
Baxslash, that was the first thing I thought of when i first had the problem. I can't see anything that would cause it as yet though. All the file names I am downloading and uploading seem okay.
Ancient Lady, I basically get "Waiting for response...". So it looks as if it is stuck at the first part on android. However as I say it has sent scores so must be doing something. The code is just the example Daniel posted as is, I have played about with it in Moon Snaker but went back to this to see if I had changed it for the worse. I wondered about that little loop also, I'll see if I can avoid or replace it.

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 5th Dec 2012 22:51
Quote: ""Waiting for response...""

If it isn't showing the percentage, then you are stuck in the very first loop waiting for a response to an http async request that was never sent.

Try removing that first loop ("While GetHTTPResponseReady(g_Net_Connection) = 0") and see what happens. I'm betting it works then and there was something a bit screwy with Windows that it somehow got a response (or timed out automagically, which is more likely).

Cheers,
Ancient Lady
AGK Community Tester
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 5th Dec 2012 23:59
It depends on the Windows version, but most Asynchronous sockets will time out eventually. Actually, most sockets have a default time-out.

Glancing at the code (I mean "glancing") what happens if no connection could be made? I think it's dropping through and assuming the connection worked. On the other hand, I could be talking rubbish.

I've just spent a week investigating possible fail conditions on a big classroom system. Turns out that the senior IT person did not do what I had asked seven days ago. It was wasn't hard - one change in an INI file. I mention this because it involved asynchronous networking and very fast computers were ahead in a race condition.

My very strong advice is that you check, check and check again for all possible fail conditions. You should be able to say "Sorry - can't connect to the high score server" etc

It's boring. But necessary. Like cleaning teeth.

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 6th Dec 2012 00:23
Quote: "check, check and check again for all possible fail conditions"

The problem with v1076 is that you don't get any error codes on any of the HTTP commands if something fails. Like the basic connection.

DVader, just to do some double checking (I hate to assume things):

Quote: "Connection.sDomain = "www.mydomain.com" //no http"

Should I assume that this was replace with your actual domain?

Quote: "Connection.sDirectory = "Scores/""

And that there is a subdirectory under your main server directory (PHP variable $_SERVER['DOCUMENT_ROOT']) named exactly 'Scores'?

And that there are files named exactly 'savescores.php' and getscores.php in that directory?

Cheers,
Ancient Lady
AGK Community Tester
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 6th Dec 2012 16:35
Yes it is very difficult to see what AppGameKit is actually doing when using these commands. A few more commands for checking connection failure would have been nice. An explanation of their use would be even nicer lol. The basic examples included don't help much when you are new to it.

I have remmed out the lines you suggested but it still locks up while waiting for the file. The percentage stays at 0. Still works on PC though.
Regarding the domain, yes I have changed "www.mydomain.com" to my domain. I would imagine that even windows would fail if not.
I am using no sub directory at all at the moment. The code above is the original code included with the online highscore board kit. Once I have it working solidly I will then reposition the various files into a folder and adjust that to suit. Savescores and getscores are both there also, both seem correct in terms of spelling and capitals. I checked this when I first encountered the androids reluctance to work.

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 6th Dec 2012 17:17
Quote: "I would imagine that even windows would fail if not."

Nope, it doesn't report a failure.

The code listed above assumes that there is the Scores subdirectory on your domain. If there isn't and it isn't named exactly 'Scores' and the files you reference aren't in it, then things will not work.

I tested the full set as well and sent my comments back to the developer. (I am a professional PHP programmer, web designer/developer/manager/hoster.)

My first comment was that if you ran the app after installing, it made no sense. The runnable thing should only be done after the database is created on your domain so that you can enter all the information and the executable creates the config.php file. Then you upload that file along with the other two files in the Script directory to the Scores directory on your domain. Did you do those steps?

Cheers,
Ancient Lady
AGK Community Tester
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 6th Dec 2012 17:52 Edited at: 6th Dec 2012 18:48
Yes I have used the scripts produced in the setup program and uploaded them to my public folder. I am not using a folder to contain any of them at the moment, they are just on the root. I will change that once it is working, as I imagine it is rather easier to hack that way.
When I setup the scripts using the program included I had to switch to my sql admin etc and set up the database first. Then I went back and put in the appropriate data. I think the file setup is okay because the PC version is working perfectly. I have Moon Snaker running fine on PC with the online score, just the android one hangs.
It's definitely something odd with the code I think, I have been playing with a snippet posted ages ago by Marco Bruti, and that from initial tests seems to be connecting on the droid. But it seems to have put in several records at once, so will need to look at it more closely, no idea why at the min.
At least I'm getting practise at the web side of things lol. I have made and deleted that database a few times now when it gets a bit too large from my tests.
Perhaps the snippet marco posted would be a better bet?

That's pretty much the same as his original, I just remmed out his http commands and put in mine from the earlier snippet. It seems a lot simpler than the original code I posted though, just not tested it much yet.
Perhaps the fact I have used gethttpfile at the end, rather than the remmed line above, has caused the multiple entries?

Edit - Sorted the multiple entry problem out by the looks. So far the code above is working better, now to test it with repeated use and then transfer to the game hopefully!

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 6th Dec 2012 19:13
Quote: "they are just on the root"

This is why it shouldn't have worked on any platform. The code you posted specifically looks in the Scores directory under the root directory for the files.

The code you just posted is much smoother and easier to debug.

I'd be happy to test your app (that is not working on the Android) on my Android devices if you send me the apk for the project. If you want to send it, I'll enable my email link on this site. I promise to delete it after testing and not to divulge any information to anyone.

I have a high score system working for my (hopefully) soon to be published game. It even has a public web site to see the leader board.

Cheers,
Ancient Lady
AGK Community Tester
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 6th Dec 2012 19:36
Thanks Ancient Lady, I will take you up on that if needs be. The first code I pasted btw was the original highscore kit code, when using it myself I removed the directory from the "scores" part. I just posted it here verbatim, I should have just deleted that part out to avoid confusion. I knew that wasn't the problem but obviously no one else did, my apologies.
I have tested the newer snippet out for repeated use and it works on android no problem. I will try it in my game and see how it performs. Hopefully it will work once I have removed the old code and put this in. I will let you know how it goes.

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 6th Dec 2012 20:10
Okay, understood.

Good luck and happy programming!

Cheers,
Ancient Lady
AGK Community Tester
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 6th Dec 2012 23:33
I have it working well now by all accounts! Cheers Ancient Lady, and all for the suggestions, I have finally got it going after numerous attempts since the release of the HTML commands I will probably update the android version soon now, just giving it a good test first.

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 6th Dec 2012 23:45
I'm glad you got it working. Cheers!

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 7th Dec 2012 15:31
Oh, btw, I like your online leaderboard for your site, is it easy to do? I was thinking of having a highscore on my own site also now I actually have the game working with one!

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 7th Dec 2012 16:38
It is all a custom job. And my database is sort of set up to handle multiple games (I am optimistic and have the second game already designed).

Within my game, you can submit your score (optional, in case you don't like the score or don't have active internet connection at the time). Then you can see any local stats (all games scores are stored on the device), or get your stats that were uploaded, or get the leader board.

The onsite leader board list uses a combination of PHP and Javascript (jQuery) to produce the table.

How familiar/proficient are you with MySQL, PHP and Javascript? (I've been doing this professionally for many years.)

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 7th Dec 2012 17:46
I am a total noob at it lol, hence most my problems getting a highscore to work. My brother has better knowledge of that sort of thing than me(he did my site), but I have more understanding now than I did just a week ago. I remember the echo command being able to post your scores on a page off the top of my head. I just think it would be a nice touch to have a web based score board as well as the in game one. I am hoping between us we will be able to suss it out with some pointers I will be having multiple score boards myself, as I have 2 games in progress besides Moon Snaker, a Christmas title I hope to release in the next few days and Obliterator which is still probably awhile off completion (I am awaiting more graphics and cannot do much more until I receive them, apart from adding online support of course!)

Login to post a reply

Server time is: 2024-04-28 07:04:56
Your offset time is: 2024-04-28 07:04:56