Detect when PhotonID come in InterestGroup, and other questions

Hi everybody !

i have multiple little question, so i group all of them here ^^ Tanks for your time!

Question 1:

I would like to know if it's possible to know when someone is new in a Interestgroup? Like OnplayerConnected, but for Networkgroup^^

Question 2 :

I create a room with RoomOption and set the max players. But how control this? If a player try to joined room and the max player is reach, the room is automaticly closed ?
There is a Callback for that ? ( if a player invite a friend to join him, but can't )

Question 3:

(For this question i took a car game for exemple)
in some case, client can send Rpc in the same time , but i need to know exactly who's the first sender , like the first player to reach the arrival in a car game . RPC send with AllViaServer do this job ?

Last question :

I have multiple room with no end. I control buffered RPC in time with "PhotonNetwork.RemoveRPCs(PhotonView)" .
the room can be play for multiple day , and more ...
This is bad ? if it is, there is a way to know since how much time the room is open?



Have a good night!

Comments

  • Hi @redskry,

    I would like to know if it's possible to know when someone is new in a Interestgroup? Like OnplayerConnected, but for Networkgroup^^


    No, there isn't a callback or similar to this scenario. If this is important for your game logic however, the client who has joined a new Interest Group can for example raise an event for that specific group in order to let other clients know, that he has joined that certain group.

    If a player try to joined room and the max player is reach, the room is automaticly closed ? There is a Callback for that ?


    There are two callbacks that might get called when joining the room fails. This depends on the function you are using in order to join a room.
    void OnPhotonJoinRoomFailed(object[] codeAndMsg)
    {
        // codeAndMsg[0] is short ErrorCode. codeAndMsg[1] is string debug msg.
    }
    
    void OnPhotonRandomJoinFailed(object[] codeAndMsg)
    {
        // codeAndMsg[0] is short ErrorCode. codeAndMsg[1] is string debug msg.
    }
    You can take a look at them here and here.

    RPC send with AllViaServer do this job ?


    Yes, RPCs should be in order of how they were received by the server. Additionally each RPC have a PhotonMessageInfo which contains a timestamp describing the moment the message has been sent. You can find an example on the RPCs and RaiseEvent documentation page.

    This is bad ? if it is, there is a way to know since how much time the room is open?


    At least this is not recommended, so you should try to avoid such scenarios. If you want to know how long a room is active, you can for example use the MasterClient and set a room property containing the moment, when he has joined the room. This describes more or less the same time the room has been created. To get the 'lifetime' of the room, you can use the current time of any client and calculate the time.
  • Thanks a lot ! This is perfect!

    For the last question, What can happen if i do it ? Imagine that a room is open since 2day ( with no buffered rpc) ?

    There is a way to kick all player in the room and close the room to avoid other player to join?

    thanks again for your help!

    Have a good day :)
  • There is a way to kick all player in the room and close the room to avoid other player to join?


    The possibility to remove players from the room has been added in version 1.89 of PUN. If only the MasterClient is left in the room he can 'close' it by using PhotonNetwork.room.IsOpen = false;. This way no other client can join it again. When the MasterClient also leaves the room, it will be removed on the server as well. This mainly depends on the settings made for EmptyRoomTtl. When using default settings, the room will be removed immediately after the last client has left it.
  • Thanks for your help !
    Have a good day !