Search Unity

Simple(?) backend/API question

Discussion in 'Multiplayer' started by realragnvaldr, Jul 21, 2019.

  1. realragnvaldr

    realragnvaldr

    Joined:
    Jul 21, 2019
    Posts:
    41
    Hi all,

    I'm developing a multiplayer turn-based game in Unity2D and i'm currently stuck on something that seem quite simple, yet i haven't figured it out yet.

    TL;DR
    Simply put, I'm looking for a service that:
    1. hosts a small amount of data (few hundred MB at most)
    2. hosts two simple functions (implemented in e.g. Java or JS)
    3. takes client requests to run the functions for a given input and sends back the response

    Background
    There are two rather simple operations in my game that I cannot do on the client because they depend on data that have to be at a server:

    1. Check if the player's proposed move is valid
    2. Find the best possible move for a given game state

    Solution that i'm looking for
    I'm looking for a solution that allows clients to send requests to a server (e.g. "here's the state of the game and this is the player's proposed move; is it valid?) which then send its response back to the client ("yes" or "no" in this example) within a few hundred milliseconds. Preferably, i'd write the implementations of these operations in Java, Javascript, C++, or C# -- the operations are quite simple, so the computation time is negligible and the response time is mainly determined by the speed data queries.

    Initial idea: use Firebase to store the data and perform these two operations
    I first thought that i would be able to do this using Firebase, but i no longer believe so, because performing these operations will either require many (hundreds to thousands) small database queries per call or one large query. The former solution is data-efficient but probably prohibitively slow (response times per query can be hundreds of ms?) while the latter is fast but probably prohibitively expensive in terms of data transfer cost.

    Other solutions?
    I'm wondering now how developers usually approach this. Do they usually have their own dedicated servers, and, if so, what software architecture do the run on? Are there other services available that allow me to do this (e.g. "Backendless" and SmartfoxServer seem more powerful when it comes to business logic?).

    Any input will be appreciated!
     
  2. MrsPiggy

    MrsPiggy

    Joined:
    Jun 13, 2018
    Posts:
    154
    I would recommend you take a look at www.smartfoxserver.com
    They have the kind of solution you're looking for. Also make sure to head to their download section and get their example package for Unity. There are some nice examples of increasing complexity that can help you get started, and they are accompanied by step-by-step tutorials in their doc website: http://docs2x.smartfoxserver.com/ExamplesUnity/introduction