Persistent rooms?

Hey there, we are wondering about having a persistent room, for example once the players reach 0, is it possible to keep the room open? If not, what if we were to setup a spare computer, which would always keep the room open? Would this be a solution? What would be the drawbacks?

Thanks!

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @HooDoo,

    Please take a look at the "Persistence Guide". And please take into consideration these "Do's and Don'ts" for PUN.
  • HooDoo
    HooDoo
    edited December 2016
    Hey @JohnTube Thanks for the info, looks like what I am looking for, is there a way to reset or clear the saved room?
  • JohnTube
    JohnTube ✭✭✭✭✭
    @HooDoo could you please explain what you mean by this:
    reset or clear the saved room
  • For example, we are doing a survival type game, and we want to make some of the rooms persistent so players are able to build houses, store their loot, etc.
    However at some point we will need to reset the room, because they may become to laggy/cluttered.
    I also do have some more questions as I am a bit confused.
    I don't know much about servers, so to have persistent rooms.. would need to host my own server, where/how would that be done? Or am I able/meant to do it through Photon?
    Secondly, would there be a max amount of rooms that could be persistent? How many could be possible to have persistent at once?

    Thanks for the support, and excuse my ignorance :p

  • @JohnTube Are we taking the wrong approach? We planned to reset the "persistent" rooms every week or two. Is this not possible with PUN? If not, what would be the best option to achieve this/which would be the fastest way to convert our code to a proper solution ? We are aiming to save/sync, buildings, items, loot boxes etc. over the period of 1-2 weeks until the room resets. Much like in the survival game, Rust.
    Looking forward to hearing your suggestions.

    Thanks!
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited December 2016
    Hi @HooDoo

    I believe what you are trying to achieve is tricky to do. The room state can become huge if you want to put everything inside. So you have to optimize how to save the room state between room properties and events cache. That's what gets persisted. Also you could do Interest Management and divide a big world into regions which are separate rooms in Photon with their own state.

    For the webhooks persistence, you need an external web service, your own self hosted or a third part.
    And please consider that the webhooks persistence solution is meant for asynchronous not too complex and mainly turn-based games (e.g. MemoryDemo) that can be played by not too many players from time to time (e.g. disconnect instead of waiting for opponent move and come back later to player a turn) without losing data. Other realtime games can make use of webhooks as well if the state can be restored easily (state is not too complex) and this is mainly for games that should need a basic cloud save feature.

    Async and turn-based games.
  • Thanks for all the info @JohnTube I really appreciate the help!
    Its good to know that it is some what possible... we save player stats/inventory locally, and once they join the game we sync them, so that would not need to be saved.
    The only things that would need to be saved to the we would be the state of the player made structures, and loot boxes. The thing is our game is defiantly not turn based
    Would the best way to be updating the save each someone builds a structure in that game?
    Also I am a bit unclear on showing the room once 0 players are connected, for example, if I was playing by myself and I built a house, the house location etc. was saved, and then I left the game, and then there was 0 players in the room, is it possible to still show that room in the list of rooms, and then for example a friend of mine could go and join that game, and see the structure I made? If not, is there a workaround?

    Thanks again for all the help
  • JohnTube
    JohnTube ✭✭✭✭✭
    Also I am a bit unclear on showing the room once 0 players are connected, for example, if I was playing by myself and I built a house, the house location etc. was saved, and then I left the game, and then there was 0 players in the room, is it possible to still show that room in the list of rooms, and then for example a friend of mine could go and join that game, and see the structure I made? If not, is there a workaround?


    Both things are possible and are mentioned in the documentation:
    - You need to save a rooms list on your web service and then query the list periodically using WebRPC. You could also still make use of Photon's rooms lists inside lobbies. The lobby type "AsyncRandom" keeps rooms for 1 hour even when empty. But the recommended way is having a HTTP method like GetRoomList.
    - It is possible to rejoin rooms and load its state using webhooks. It is even possible to do async. join: you create a room and send an invitation containing room name to another player. You leave the room and your friend can still join it after a while.
  • Thanks @JohnTube
    I will do some more research and let you know if I have anymore questions!
  • I have a survival game with persistent items using PUN+. If a server reaches 0 players, I just fake that it is still running. And all the persistent items I save in my own PHP/MySQL backend.

    It can be done fore sure, as I am using it too, but it's a lot of coding.
  • JohnTube
    JohnTube ✭✭✭✭✭
    Hey @chaozz,
    I just fake that it is still running.

    Can you please tell us what do you mean by this? do you use webhooks for room state persistence? is that it?
  • Hey @chaozz, really interested in this.
    Do you mind sharing in a bit more depth how you achieved this? We are pretty confused on where to get started!
    I saw your project Survius, looks great. I noticed you said that it has a modular building system, so for example if someone were to build a house in a server, and then they left that room, so now that room has 0 players, would other players be able to see that room? And would they be able to join it, and see the building the first player made even though he left the game and is not currently in the game?

    Thanks!
  • @HooDoo

    Yes, if all players would leave the server, I just add it manually to the "server list". So if a room (I call them servers in my game) is uninhabited, I just add it as Server EU#1 0/0 for example.

    All persistent objects are saved to a mysql server. The first player that joins an empty server loads the objects. Pretty simple stuff, a lot of fun to code and conceive. Challanging stuff. But yeah. It's all persistent in Survius, using something non-persistent as PUN+
  • did you go down the path of using webhooks to save your objects? And are you self hosting or using the cloud? I had the idea I could self host using photon on premise and run PUN on top of that but I'm getting different messages online about how far PUN can be tweaked to use webhooks. You'd have to using something like that if the player[master] client can load current saved data on joining the room?
  • I wrote my own PHP / MySQL backend and just use WWWFORMs to access my backend. Works like a charm :)
  • Hm. That is sneaky. So the first Masterclient in the room downloads the saved game state, and the last masterclient in the room uploads/saves the game state. Genius mate!
  • @carcer @chaozz
    Great information, Chaozz, seems like a great way to go, I just wonder how fast it would be downloading the persistent objects from the web sever on mobile, especially if we are saving lots of information.
    I will pass this on to our programmer!
    Will most likely have some more questions about your technique.
    Thanks for all the information, I really appreciate it. :smile:
  • @HooDoo no problem. And the only thing you need to load is vector3's and perhaps gameobject names. It's pretty fast.