Search Unity

Photon server side logic

Discussion in 'Connected Games' started by TheDavvyd, Feb 7, 2019.

  1. TheDavvyd

    TheDavvyd

    Joined:
    Feb 15, 2015
    Posts:
    1
    We are making multiplayer platform for multiple small games.

    we would like to do all game logic on server side to prevent cheating.
    also every room would need its own logic. as player is able to change game modes and game types.
    we do not require physics or simulations.

    is this possible with Photon or photon server+plugins ? and what are we losing by not using photon cloud ?
    Are there any better options that we should check out ?
     
  2. MrsPiggy

    MrsPiggy

    Joined:
    Jun 13, 2018
    Posts:
    64
    I'd recommend also checking SmartFoxServer 2X, it's a very solid product for projects that require server side coding and it's highly customizable.

    Cheers
     
  3. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    360
    Yes

    You need to pay OnPremise license fee, it's expensive somewhat if your server can only serve for a small number of players concurrently


    Headless server and other network solution, see also https://github.com/nxrighthere/BenchmarkNet/wiki/Benchmark-Results

    Yes, it's a solid product, but I'm not so sure about if it's a proper alternative to Photon. IIRC, SFS uses Java/JS as its server-side language.

    1. Photon do the serialization/deserialization for you, you may have to implement it your self in other solution, something like StreamWriter.WriteInt and StreamReader.ReadFloat.

    2. Photon plugins are pure C# projects, which means you CAN NOT use anything from UnityEngine, there're some tricks/hacks but no guarantee.

    3. Actually, there are lots of other things you need to know before you start if this is your first multiplayer game, https://gafferongames.com/ is a good site for essential knowledge. If you've already known what you're going to do, then you're good to go, good luck :)
     
    Last edited: Feb 12, 2019
    tobiass likes this.
  4. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,175
    Technically, this is the safe approach, yes. You will have to make sure you can run a lot of instances per server, or this easily becomes a very CPU intensive and costly approach as you run the full game (headless) per room.
    Also, you have to manage the instances and it affects matchmaking, etc. Unity's Multiplay and other services do this for you but then you're using a service once again.
    I'm not saying you should not do this. Lots of games do, in fact. But you are trading some problems for others.

    This means the benefit of running headless instances will be minimal.
    Your case is pretty much perfect for the Photon Server Plugins. You can run your own abstract logic on the server, prevent cheating and customize the in-room logic to your needs. You could create one assembly for game functionality, which can be run on the server and on the client.

    Without the Photon Cloud, you have to take care of the servers and set them up per region (if you wanted to). I would say it's not as complicated as running headless instances, as your server SDK provides the tech to scale it and it covers the matchmaking. The client will run with the Photon Plugin SDK as is.


    Preventing cheating and hacks is an ongoing battle. You're never done.
    We recommend using IL2CPP and client-side anti cheat packages (there are some in the Asset Store but I don't know enough to recommend either).
    The cheapest solution we came up with, so far, is to make the clients verify the actions of others. You will need to identify users/clients which hack/cheat and report them. Of course, this requires a backend service, which accepts reports (and identifies fake cheater-reports). This service can be independent from Photon or integrated with WebHooks in the Photon Cloud (without plugin or custom server).
    When you can ban cheaters with their accounts, your anti-cheat protections will make a difference.
     
    zhuchun likes this.
  5. Munchy2007

    Munchy2007

    Joined:
    Jun 16, 2013
    Posts:
    1,202
    @tobiass
    Do you have any example of how something like this might be implemented?
     
  6. MrsPiggy

    MrsPiggy

    Joined:
    Jun 13, 2018
    Posts:
    64
    If this is off topic sorry for posting, but...
    ... isn't this a bit convoluted as a system? Having to set up an external backend with the purpose of filtering out cheating requests via HTTP calls sounds like a pretty inefficient system. Even a mildly fast game (i.e. 5-10 req/s) would have to fire so many back-and-forths with the external backend that it would make scalability a pain in the neck.(Not to mention the extra latency it introduces)
    Personally I would not recommend this route, as it seems too clunky and potentially detrimental to the growth of the game.
     
  7. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,175
    @Munchy2007: Sorry for the delay. There was a misunderstanding with a colleague, who replies. The bad news is: We don't have a sample for this. Sharing such a sample is much more complicated, as you need the accounts, backend, etc.

    @MrsPiggy: I agree, this would only work for games where players take turns and when there are not too many game-relevant updates/sec. However, the part you quoted is about making the clients check one another (in the engine) and only report misbehaviour. That could be done with a few requests every now and then.
    Of course, the report system itself needs sanity checks, too. As said: This is an endless battle pretty much.
     
  8. Munchy2007

    Munchy2007

    Joined:
    Jun 16, 2013
    Posts:
    1,202
    Okay np, I kind of suspected as much.