Difference between PhotonRoomProperties and RoomProtocolToken

I'm learning Bolt and I'm following the tutorial here. When creating a room, the tutorial passes in a RoomProtocolToken to SetServerInfo(), while the sample code here uses PhotonRoomProperties. AddRoomProperty().

May I know what's the difference? Thank you!

Best Answers

  • ramonmelo
    ramonmelo mod
    Answer ✓
    Hello @donovan ,

    Yes, there are some differences, but first, both are classes that implement the IProtocolToken interface and can be passed as extra data to certain operations on Bolt.

    The RoomProtocolToken is just a simple Token that comes along with the Sample Package and exists just as an example, as so you can use the Token without creating it, in order to get a simple string passed by the server to the client, this can be like a map or a character to load.

    On the other hand, PhotonRoomProperties is an internal Token implemented inside the Bolt SDK, that you can use to configure a room when using the SetServerInfo() function. By using this token you will be able to set the visibility of the room and/or some custom properties, so your clients will be able to know which type of game are you running (free-for-all or a team match for example), but these properties can be anything that is more related to your game.

Answers

  • ramonmelo
    ramonmelo mod
    Answer ✓
    Hello @donovan ,

    Yes, there are some differences, but first, both are classes that implement the IProtocolToken interface and can be passed as extra data to certain operations on Bolt.

    The RoomProtocolToken is just a simple Token that comes along with the Sample Package and exists just as an example, as so you can use the Token without creating it, in order to get a simple string passed by the server to the client, this can be like a map or a character to load.

    On the other hand, PhotonRoomProperties is an internal Token implemented inside the Bolt SDK, that you can use to configure a room when using the SetServerInfo() function. By using this token you will be able to set the visibility of the room and/or some custom properties, so your clients will be able to know which type of game are you running (free-for-all or a team match for example), but these properties can be anything that is more related to your game.
  • Hi @ramonmelo ,

    If I'm understanding correctly, anything that can be done with a custom Token (e.g. RoomProtocolToken) can be done with PhotonRoomProperties? Then why is there a need to define a custom Token in this case?

    Thanks again!
  • The confusing bit to me is, why is that argument of the base token interface rather than just being a PhotonRoomProperties ? If the only way to configure your room for eventual discovery, matchmaking, etc is to pass a PhotonRoomProperties, why does it allow just any old token class? Seems like it would be better to take a PhotonRoomProperties argument, and then give you the option to register a subclass of PhotonRoomProperties to extend it with custom data, rather than writing your own token and then presumably being unable to configure the room properly. That way the internals can always expect it to be a PhotonRoomProperties and useful for configuring the room properties and you don't give up functionality if you have a need to make your own.
  • Hello @JeremyS

    You are not abligated to use PhotonRoomProperties, this is just an extension class that you can use to have a more fine control of how the room will behave (visible/open). If you want to pass data to your clients when they connect to the room, fine, use a normal IProtocolToken with any data layout you want.

    The idea of PhotonRoomProperties is to be used by filtering (not yet implemented), as you are able to set custom properties on the room, and then search for the ones that you want to connect to.

    Sure, we could make it extensible, so you can add more data to the token, but this is not our intention at the moment. In summary, you can just use the regular IProtocolToken and it will work just fine.