- Home /
Web Player and DB communication
So how would the web player communicate to a DB backend. It has to somehow or that Tiger Woods game would not work. Do I have to send messages to my web browser which in turn sends JSON messages to a DB middleman like Rails?
Answer by duck · Jan 17, 2010 at 05:43 PM
Yes, the 'middle-man' idea is pretty much correct. You use the WWW class in Unity to make POST or GET calls to scripts which reside on your server, which in turn talk to the database which is often also on the same server.
These server-side scripts are generally written in php, asp, perl, or some other server-side scripting language. The scripts receive data from your webplayer and then talk locally to the DB. If the data is sufficiently complex, you might want to use a data format such as JSON, however often it's enough to just have a few named parameters which the script accepts.
There's a good example in the manual which shows you how you can use these features to send and retrieve high score data to a server-side scoreboard, here (it's after the PNG example):
http://unity3d.com/support/documentation/ScriptReference/WWWForm.html
I know the Web player for Unity is for... Duh... Games. But I saw a lot of users of Unity use it for non-Game apps, but usually fairly graphical ones. That is what I am thinking. To not only develop games in Unity, but to also use it to develop an RIA for my day job ins$$anonymous$$d of use of Silver Light or Flex/Flash because the Unity Web player is meant to be interactive where (at least flash) is a modified movie file.
Yes, you can send whatever data you like via the WWW class. Eg, the other example on that page I linked to shows how you can send a PNG file to your server.
Whether unity is a suitable platform for whatever RIA you're considering is another matter, however! :-)
Answer by Ashkan_gc · Jan 17, 2010 at 07:34 PM
games like tiger woods or fusion fall use .NET sockets to connect to other applications using TCP/UDP ports. for database connectivity you can use the above approach or use DB connectivity APis. then you can use ODBC to manipulate your database. take a look at these links database connection i think you can use many of the managed providers too but i did not test it. sockets the serverside script based approach is good in some situations if you know server side scripting languages well.
Your answer
Follow this Question
Related Questions
Unity Web Player Failed To Download Data File 1 Answer
Retrieve the data from the Webserver Database 0 Answers
Webplayer<->Database 0 Answers
SQL in web player 3 Answers
Saving Huge strings over the web 3 Answers