Simple leaderboard example with Gamesparks

Somebody asked me for a simple example of how leaderboards work in Gamesparks. It is here if anybody else is interested:

https://youtu.be/LMua–qGzjA

https://github.com/agramonte/gamesparkscoronaleaderboard

Thanks for doing this!

Rob

I was looking for this! Thank you :slight_smile:

Anytime. Let me know if you run into any problems.

Video tutorial and the sample code really worked for me but still, I’m a bit lost. Apart from the GameSparks documentation in which I got lost, I’m having a problem with following some of the error cases.

I encountered this during a bad connection phase in my workplace and tried to reproduce it. In the code, I seem to get availability callback to work during some of the connection attempts but for some reason, it is not called with further attempts. This is where I got the “INCORRECT APIKEY / APISECRET” error from the showGSlog function.

Anyway, I tried to reproduce it with intentionally entering the wrong key. I managed to get the exact same error message but it doesn’t go through any of the listeners I set up. It seems that the only way I can handle a bad connection / wrong key issue is through string comparison which is pretty unreliable. Do you know if I’m missing out on something?

No. I have not experience that. Although my game doesn’t matter if they are connected for most things so I don’t bother to try and re-connect. You might try opening up a ticket with Gamesparks. They usually respond fairly quickly.

@bgmadclown

I am seeing this issue to. I have a project that works very well when the connection is stable, but on bad connections 3G or below (I test this with the Network Link Conditioner) it throws the “INCORRECT APIKEY / APISECRET” error when gamesparks is connecting. After that it closes down the socket connection.

I wonder what the keys have to do with the connection stability? Very strange.

Did you get any further with this issue? 

Thanks, Jacob

I suspect both of you are using the plugin version. If you download the open source version you can actually look at the code. It is all lua. That error “incorrect apikey/ apisecret” is written out by a long if / then statement. By typing the incorrect api key you are not really reproducing the error you are just hitting the same if statement with a different condition. 

So if I simulate a really slow connection then I also experience the error, but I have tried my game on a real 2G phone without any issues. You can capture the error and let the person know that they have a connection two slow to play the network parts of the game by presenting some sort of alert. This has been enough for me although technically you can print the response and see exactly what is going on. Here is the code in question. It is line 212 of GS.lua it just checks for an error and throws that message in the logs. I suspect the actual error is “connection request timed out” or something like that. Hope this helps.

elseif response["@class"] == ".AuthenticatedConnectResponse" then if response.error ~= nil then log("INCORRECT APIKEY / APISECRET") self.disconnect(true) return end if response.sessionId ~= nil then self.sessionId = response.sessionId end

 

Sorry about not updating this. I haven’t had time to file a report with GameSparks but I guess it will be logical to follow agramonte’s advice. I’m a bit lost in the repo at this point but I’ll try to figure it out. At this point, I think it may be something that slipped their attention.

https://bitbucket.org/gamesparks/gamesparks-corona

@agramonte, does that mean I have to search for a class named AuthenticatedConnectResponse? If so, how do I know which file it’s located at?

Unless I am miss-understanding your question. It is on line 212 on GS.lua. Here is what it looks like on my version. In this game, I log the error to flurry, but technically you can do whatever you want with the response from the call.

Actually, I didn’t want to get my hands dirty by diving directly into the code. I wanted to find the code piece where it directs to the listeners just like the other function calls. Even though there is a response error in the code, it doesn’t return a value in the listeners.

Anyway, I guess I’ll follow your advice and include the plugin as a library and modify it a little bit. I’ll also ask their support if there is anyway I can get that response and I’ll post here if I get a solution to the problem (or find the solution myself).

Thanks for doing this!

Rob

I was looking for this! Thank you :slight_smile:

Anytime. Let me know if you run into any problems.

Video tutorial and the sample code really worked for me but still, I’m a bit lost. Apart from the GameSparks documentation in which I got lost, I’m having a problem with following some of the error cases.

I encountered this during a bad connection phase in my workplace and tried to reproduce it. In the code, I seem to get availability callback to work during some of the connection attempts but for some reason, it is not called with further attempts. This is where I got the “INCORRECT APIKEY / APISECRET” error from the showGSlog function.

Anyway, I tried to reproduce it with intentionally entering the wrong key. I managed to get the exact same error message but it doesn’t go through any of the listeners I set up. It seems that the only way I can handle a bad connection / wrong key issue is through string comparison which is pretty unreliable. Do you know if I’m missing out on something?

No. I have not experience that. Although my game doesn’t matter if they are connected for most things so I don’t bother to try and re-connect. You might try opening up a ticket with Gamesparks. They usually respond fairly quickly.

@bgmadclown

I am seeing this issue to. I have a project that works very well when the connection is stable, but on bad connections 3G or below (I test this with the Network Link Conditioner) it throws the “INCORRECT APIKEY / APISECRET” error when gamesparks is connecting. After that it closes down the socket connection.

I wonder what the keys have to do with the connection stability? Very strange.

Did you get any further with this issue? 

Thanks, Jacob

I suspect both of you are using the plugin version. If you download the open source version you can actually look at the code. It is all lua. That error “incorrect apikey/ apisecret” is written out by a long if / then statement. By typing the incorrect api key you are not really reproducing the error you are just hitting the same if statement with a different condition. 

So if I simulate a really slow connection then I also experience the error, but I have tried my game on a real 2G phone without any issues. You can capture the error and let the person know that they have a connection two slow to play the network parts of the game by presenting some sort of alert. This has been enough for me although technically you can print the response and see exactly what is going on. Here is the code in question. It is line 212 of GS.lua it just checks for an error and throws that message in the logs. I suspect the actual error is “connection request timed out” or something like that. Hope this helps.

elseif response["@class"] == ".AuthenticatedConnectResponse" then if response.error ~= nil then log("INCORRECT APIKEY / APISECRET") self.disconnect(true) return end if response.sessionId ~= nil then self.sessionId = response.sessionId end

 

Sorry about not updating this. I haven’t had time to file a report with GameSparks but I guess it will be logical to follow agramonte’s advice. I’m a bit lost in the repo at this point but I’ll try to figure it out. At this point, I think it may be something that slipped their attention.

https://bitbucket.org/gamesparks/gamesparks-corona

@agramonte, does that mean I have to search for a class named AuthenticatedConnectResponse? If so, how do I know which file it’s located at?

Unless I am miss-understanding your question. It is on line 212 on GS.lua. Here is what it looks like on my version. In this game, I log the error to flurry, but technically you can do whatever you want with the response from the call.