Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Advice on (Easy) Client Server Networking

Discussion in 'General Discussion' started by Ogien, Dec 24, 2017.

  1. Ogien

    Ogien

    Joined:
    Nov 21, 2012
    Posts:
    165
    I need some advice on implementation. I need a simple server that allows clients to save & read data to and from a server. The data itself is going to be simple a few strings. There will be no login required but maybe a unique identifier from the client side so no duplicates are added. I can see the data being stored in a single table.

    Now I know I can get an Azure server and install a SQL database and create a Web Service and simply call that web service from Unity. However its 2017 (almost 2018) so there should be an easier way like though some Cloud Service.

    For example Microsoft Azure has something called Azure App Service which basically takes care of the storage/webservice part. However I have not seen any good Unity examples that would work on Mobile (Android & iOS). The Microsoft video that shows an implementation for Unity was for desktop and it was very painful.

    So my question is what is the easiest way to implement this. I don't mind paying for hosting costs like through something like Photon, however I don't want a standard multiplayer solution which is what they seem to offer. I just need to send and read some user data to a server in the easiest possible way.

    Thanks for your help
     
  2. Tiny-Tree

    Tiny-Tree

    Joined:
    Dec 26, 2012
    Posts:
    1,314
    easiest and cheapest solution for now would be to use a backend tailored for game, gamespark offer 100k MAU for free which is far beyond other solution for free tier
     
  3. Ogien

    Ogien

    Joined:
    Nov 21, 2012
    Posts:
    165
    Thank you I will check out Gamespark, have you used it in your games?
     
  4. grimunk

    grimunk

    Joined:
    Oct 3, 2014
    Posts:
    270
    Do you need to be server-authoritative? Playfab and (Amazon) Gamesparks can offer the persistence stuff, whereas you could use something like photon for the real-time aspect.
     
  5. Ogien

    Ogien

    Joined:
    Nov 21, 2012
    Posts:
    165
    Yes it has to be server-authoritative. Don't really need multiplayer or leaderboards just needs to save some data for each player. I will check out Gamespark.
     
  6. Tiny-Tree

    Tiny-Tree

    Joined:
    Dec 26, 2012
    Posts:
    1,314
  7. Chris-HG

    Chris-HG

    Joined:
    Aug 10, 2012
    Posts:
    63
    The Googles have many APIs you can use: https://cloud.google.com/storage/docs/json_api/

    I personally use http://exist-db.org.

    Code (csharp):
    1.  
    2. xquery version "3.1";
    3.  
    4. module namespace space1="http://meow.com/space1";
    5.  
    6. declare namespace json="http://www.json.org";
    7. declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization";
    8.  
    9. declare
    10.     %rest:POST("{$payload}")
    11.     %rest:path("/space1/post2")
    12.     %rest:consumes("application/json")
    13.     %rest:produces("application/json")
    14.     %output:media-type("application/json")
    15.     %output:method("json")
    16. function space1:post2($payload as xs:base64Binary)
    17. {
    18.     let $json := util:base64-decode($payload)
    19.     let $realjson := parse-json($json)
    20.    
    21.     return element root {
    22.         element thatsometingis { $realjson?something }
    23.     }
    24. };
    25.  
     
    Last edited: Jan 24, 2018