Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Kinvey & Firebase added to Gideros REST API library — Gideros Forum

Kinvey & Firebase added to Gideros REST API library

ndossndoss Guru
edited May 2012 in Code snippets
Added support for Kinvey and Firebase to: https://github.com/KosiDossApps/gideros_restful_apis

Here's a quick video that shows writing/reading lua tables to/from Firebase. When the app runs, data immediately shows up in my desktop web browser.



Kinvey & Firebase make it very easy to read and write lua tables to the cloud. For example, the following writes a table (the 3rd argument) to the "example" collection and names the table "mydata".
kinvey:create("example", "mydata",     { name="myname", a=4, b=5, list={ 34, 35, 36 } }, handler)
Here's a firebase example which writes a table to "new/data":
firebase:write("new/data", { gideros = "Gideros Mobile", thisIs = { anExample = { ofANested = "table" } } })
You can read the whole table like so:
firebase:read("new/data", function(r)   ... r.data will contain the table ... end)
You can also retrieve just a portion of the table:
firebase:read("new/data/thisIs/anExample")   ----> returns { ofANested = "table" } in the response
The example uses my account at: http://gamma.firebase.com/ndoss. If you point your web browser to that location, you can can see the data that's been written.

--ND
+1 -1 (+6 / -0 )Share on Facebook

Comments

  • Very cool, I'll certainly be thinking about using that in the future on a few games :)
    ThumbHurt Games / FB: ThumbHurt Games / FB: Eli/Teranth | Skype: teranth37
  • This looks awesome! Is there a similar read call for kinvey to retrieve an entire table?
  • This looks awesome! Is there a similar read call for kinvey to retrieve an entire table?
    Yes, there's a get (https://github.com/KosiDossApps/gideros_restful_apis/blob/master/kinvey/kinvey.txt)
  • Ok, I saw the get and see the print statement it does, but must have been doing something else wrong. Think I might see what it is, thanks!

    Likes: anefiox

    +1 -1 (+1 / -0 )Share on Facebook
  • zvardinzvardin Member
    edited July 2012
    I had been testing this in the Player on my PC and everything seems to work fine, however when I test in the player on my Android I seem to get no data returned. I'm rather new to mobile development so I'm wondering if some sort of Android security feature is getting in the way maybe? Any ideas would be greatly appreciated, thanks!

    If I add some print statements for debugging in the handler, r.data is a table, but there seems to be nothing inside it if I try to iterate over the pairs. (On the PC, the game state loads as there is a ents object in r.data.)
    local function loadGameHandler(r)
    	print("kinvey handler")
    	print(r.data)
    	for k,v in pairs(r.data) do
    		print(k, v)
    	end
     
    	if r.data and r.data.ents then 
    		game:loadState(r.data)
    		--startGame()
    	else -- no info found so add some stuff
    		print('ok start new game')
    		startNewGame()
    	end
    end
    kinvey:get("ProjectX", "gamedata", loadGameHandler)
  • I also get errors trying to run the Kinvey example you have included on my phone (although the example works in the player on my PC.) The errors vary and sometimes it kills the Gideros player entirely. Some of the output is like so:

    --------------- ping
    ERROR
    URL: https://baas.kinvey.com/appdata/kid1497/
    --------------- getUser
    ERROR
    URL: https://baas.kinvey.com/user/kid1497/4fc4750ec9f1ba140b000226

    Also interesting, sending information seems to work correctly (the create call).
  • atilimatilim Maintainer
    oh.. I will definitely look at it and update this thread when I catch something. thanks.
  • Thanks @atilim, I tried looking at the lua and wondered if it was related to only UrlLoader.GET calls. (I was hoping maybe I just missed something obvious in my inexperience with Gideros)
  • Sweet! @atilim thank you so much for the bug fix with UrlLoader.GET on Android devices, my code works now :) Had to test as soon as I saw that bug fix.
Sign In or Register to comment.