Extracting Event Data and Player Management in a Room

Options
Howdy! I've been scouring the web, api docs, and the source for Photon Turnbased, as well as the LoadBalancing code. Having a hard time finding this info, so I figure I'd give it a shot to post here. I'm creating a card game in Unity right now, but I haven't installed/used the PUN yet.

In OnEvent(EventData photonEvent) for the LoadBalancingClient, I recognize you can switch on photonEvent.Code to find out what type of event it is, but I'm having a hard time finding out how to know which parameters are being filled, and what kind of data they have inside of them.

Some of the events cast the parameter to an int, or an int array, or a Hashtable.

So, two requests:
  • Is there some documentation that I'm just missing, that describes all the parameters being passed with these events, and what their types are?
  • Failing that, some example code to just debug the event parameters to figure out what I should be casting to, as well as the available parameters, would be awesome as a last resort.

As for player management, a couple more questions:
  • In multiple places, we're told to watch the race condition that can occur with two players joining at the same time. What happens when that extra player joins over the MaxPlayers limit? Is it up to the MasterClient to remove them, or will they be removed automatically?
  • On that note, even if the removal is automatic, I could see a host wanting to control players in a match during the round-setup. How do I kick/remove a player with the non-PUN API? (I'm using Unity, but currently only using Turnbased and LoadBalancing.)

These are definitely some of my pressing questions for now, any help is greatly appreciated!

Comments

  • Tobias
    Options
    An event always has a code and a .Parameters Dictionary<byte, object>. The actual content (keys and types of values) depend on the code of the event.
    The class ParameterCode contains keys we defined as event parameters.
    This part is defined by us, along with several events for Photon. You usually don't have to handle the pre-defined ones. This is done by LoadBalancingClient or PUN's NetworkingPeer class.

    Much more important for you are the custom events where you make up code and define some content you want to send. You make up your code (let's say 1) and put in a string (e.g. some message).
    With the event.Code you find your own, custom events and then find the sent content as event.Parameters[ParameterCode.CustomEventContent]. In the example, this would be a string.

    For your questions:
    1) The documentation for those topics is a bit scattered. Turnbased uses the same API as Realtime but doesn't have the same amount of online documentation yet. You can take an additional look at the Realtime docs:
    http://doc.exitgames.com/en/realtime/current
    Aside from that, we will try to answer any question.

    2) The EventData class has a ToStringFull() method. This can be helpful, even for your own, custom content.

    3) The Master Server makes sure there are not too many players joining. This is one case you don't have to worry about. In best case, simply use OpJoinRandom (with or without a matchmaking Filter) and let the server do the handling. Players who all want to join the same room can use OpJoinOrCreateRoom with the same room name.

    4) You would have to send a custom event to the player who should leave. At the moment, we do not support kicking as such, as we want to make sure it's not going to get abused.


    The trick is that your clients make up most of the events and their content, so you also know what's inside.
    The event .Parameters is