Creating an authoritative .io/mmo style server using Photon's plugin SDK

Hello,

I think that after reading enough photon documentation I have an idea how to create a custom authoritative server by implementing a custom plugin and was hoping for some tips/feedback in that correct direction.

For background: I'm writing a photon server for a game that looks like a .io game (think agar.io,slither.io or more closely glor.io). I'm hoping to support up to 100-300 players on the same server in a single room. The clients will be using Unity and run across many platforms including web, pc, mobile and maybe even console one day. It's my understanding that the MMO example is now pretty old/out of date, and because I'd like Exit Games to host the code in the cloud that can't use the MMO example, and need to write plugin code anyways.

With that preamble in mind it looks like I need to do the following to create a custom authoritative game server:
  • Write a custom plugin based off of PluginBase
  • When a room is created, I create my own ServerGame instance which uses a repeating timer for the simulation tick.This tick runs the server side simulation of a bunch of game objects and AI elements.
  • Have the clients use RaiseEvent to send their inputs to the server (eg. I'm moving to the left, or I'm firing a bullet)
  • Use the IPluginHost.BroadcastEvent to send updates from the server to the clients who then do some interpolation etc. These events will only be send to clients in the correct "Interest Area", to reduce bandwidth requirements and get as many players as possible.
Is the above understanding roughly correct? Is there any code that I should steal from the older MMO example to make this easier?

Any feedback would be helpful!

Thanks,
Curt

Comments

  • Hi, Curt
    >Is the above understanding roughly correct?
    yeah, it is. i'm not sure only about this: When a room is created, I create my own ServerGame instance. what do you mean hier?

    >Is there any code that I should steal from the older MMO example to make this easier?
    you may try to use Interest managment, but probably it would be easier to write it from scruch

    best,
    ilya
  • Thanks Ilya. What I meant by Server Game Instance is that every time a room is created I effectively create a new game that is run server side. The server knows the map, where enemies and items are etc. and simulates the enemies running around etc. and passes this information to the clients at 10 packets per second. In a given room there might be 300 people or so. When that room fills up, a new room is created and that will effectively be a completely different instance of the game with separate players.

    My understanding is that there is one instance of a photon plugin per room created, so I'm thinking the easiest way to handle this is to have one separate game simulation run by the server per room.

    Is that correct?
    Thanks,
    Curt
  • well, yes, only one plugin is created by server per room. so, your plugin may simulate everything and send to clients

    best,
    ilya
  • Hi Ilya,

    So one other question... I was looking at another post of yours regarding having a Photon plugin start an instance of Unity to use as the master server. i.e. that unity process will become the authoritative server, though photon's server code would just treat it as the "master client".

    I was starting to write my server simulation from scratch inside the Photon plugin and realized that it was totally doable, (I've written game engines from scratch before) but maybe just using an instance of a Unity executable as the server might be even better as I don't have to write everything myself ;-). I did have some concerns about this approach though which led to some questions:

    - Do you know if anyone has done this in a live professional game?
    - Does it scale well if the game gets lots of players? (The concern being that unity is a relatively heavy engine if you're just using it for a server-side simulation)
    - If a Photon Plugin creates a windows Unity process on room start and then transfer master client status to that client, how does that client then ensure that it's connecting to the correct game server? Do I get the room name from the ICreateGameCallInfo class and then pass that room name to the unity process that will become the master client/server and then join that same room name?

    Thanks again for your help,
    Curt
  • chvetsov
    chvetsov mod
    edited May 2017
    hi, bererton
    EDT:
    well, this plugin is still in beta. it is not released and not supported. so you need to implement server side your self

    best
    ilya
  • Ah, well I've managed to make my own custom photon plugin that runs my Unity executable when a room is created which then becomes the master client. This master client then effectively becomes the "authoritative server". So it seems to be working for me on my local machine at least... But you're saying that this isn't officially supported so I should still write my own C# authoritative server from scratch as a custom plugin then?
  • A further question after re-reading your previous post. It sounds like ExitGames is *working* on what is effectively a Unity plugin that could be run in the cloud, but that it's not released and not supported *yet*.

    If that's the case is there any estimated time for when it might be out in beta? Sounds like it's pretty far away and I should probably write my own authoritative server directly into my plugin source code then?

    Thanks,
    Curt
  • >If that's the case is there any estimated time for when it might be out in beta?
    well, it is quite long in such state. so there is no clarity about it

    >But you're saying that this isn't officially supported so I should still write my own C# authoritative server from scratch as a custom plugin then?
    if it works for you, please use. but i personally think that is better to write your own plugin than use Unity. but this is just my opinion and i do not have much exprience in this area

    best,
    ilya
  • Well, I think that because this isn't officially supported, I think I'll just go ahead and write my own authoritative server... seems too risky to go down an unsupported path and I'd really not rather host my own servers. Been there, done that, didn't like the pager calls at 3AM ;-)
  • happy coding
    your questions are always welcome
    best,
    ilya