Send message to everyone on Photon?

Options
Hi everyone,
I am trying to send a message to everyone connected to photon, but it seems this isnt possible. Am I wrong?

I will try to simplify this as much as I can. The goal is this > Divide the game into "fictional" servers by 100 people. Everyone gets a serverNumber at the beginning based on the number of players (serverNumber = PhotonNetwork.countofplayers), which determines to which server you should belong - for example if you get serverNumber 101 you belong to the second server (because the first is "full"). This is already done.

Now, when someone from the first server disconnects, I want to send message to everyone with bigger serverNumber so that their serverNumber decreases by 1. So if 20 people from first server disconnect, then 20 players from second server automatically get moved to first server. The question is, how do I get list of all players on photon, to send message to them?

Because it might not be even possible, can you give me any advice on HOW should I approach this problem? Would you do it differently? Thanks a lot...

Best Answers

Answers

  • vadim
    Options
    Hi,

    Do you mean 'room' when writing 'server'?
    There is no way to send message to everyone in PUN. You can either send from player to player joined same room or update room properties so that players joined a lobby get these updates ("sending" from room to lobby that way).
    Another option is to have chat client in same application working in parallel and allowing clients communicate even if they are in different rooms or lobby.
    2nd LoadBalancing client will work same way but can connect same lobby as PUN clients use.
  • SamPav
    Options
    Hi :)

    What I meant by server was to "divide" the lobby into several lobbies, where each "lobby" is no bigger than 100 players.

    To make it less theoretic - it is an educational project in VR, where users can help each other to learn anything. It is quite critical for the project to make sure users dont see a huge list of rooms when they want to help someone - thats why I want to somehow divide the project into several parts (imagine it like a virtual school that is divided into mini-schools by 100 students..).

    There is another thing I just tried, perhaps someone can help me with it. (This should be possible, unlike the messages to everyone...)
    I made a list that assigns a serverNumber to each new user and if someone disconnects the number goes back to list. Example : There are 500 users (divided into 5 "servers" by 100 ), and someone from the first "server" disconnects. The next user who connects goes to server 1 - this was my goal all along, I just didnt articulate it clearly I guess, sorry for that.

    The code for the list is already written - my question is How do I make sure the list exists on the network and updates for everyone??? Do I need my own (real) server for this? If so, can someone point me into any learning materials how to set up my own server? I have used photon for some time, but have absolutely no experience with this kind of problem...

    Thanks a lot for any answer! :)
  • SamPav
    Options
    To put it even more simply - if I want a list of integers to be synchronized for everyone on photon, can it be done directly via photon or do I need some kind of webserver where I post and read data?
  • Tobias
    Options
    From the unity forum:
    Yes it does seem quite wasteful, I already figured out a better way to do it, I think. I created a list that gives a number to each new user (based on this number it divides users into "lobbies"). Now, what would be the best way to sync the list for everyone - it seems like I would need a webservice for that....or can it be done by adjusting the photon server SDK as well?
    You can do any sort of communication with Photon Server, yes. And no, you probably shouldn't do it.

    Again: It might be wasteful to send complete lists of users/IDs to everyone, when the list changes.
    Just imagine what happens when there are 1000 or 10000 active users in your popular game?!

    For multiplayer games, you always need a solution that scales and doesn't waste bandwidth or you're out of business when your game wants to take off.

    If you let us know what you want to achieve, rather than what you think you need to do, then we might exchange ideas. Otherwise, we can't help.
  • SamPav
    SamPav
    edited March 2016
    Options
    Yeah, I understand now, thanks to both.

    My point is the same though - I would like to separate/divide users into lobbies (so 1-100 connected users are on the first lobby, 101-200 on second etc). The reason is, as I wrote above - it is critical for the project to make sure users dont see a huge list of rooms when they want to join someone.

    The solution, I think, would be this - make a list on webserver and when a user starts the game, he gets a number from the webserver (so first user gets 1, second 2, third 3....). Based on their number, they get divided into a lobby (so if someone gets number 105, he connects to second lobby).

    When a user gets his number from the list, the number should be removed from the list ( so that next user doesnt get the same number). NOW, I dont want to send the message to all, it would be indeed stupid as you said. But it should be somehow possible to make a list that is basically dynamic - so if I remove the number from it (list.RemoveAt(0)), the next user gets the next number. Is it understandable?

    My main question is if I would need my own webserver for this, as I have no experience with setting up/maintaining my own. I can learn it of course, just asking you guys if you think it is necessary for something like this.. Thank you very much for all the answers.