Can someone explain Photon.SocketServer.SendParameters?

Options
Context: I want to publish an event from the server using Room.PublishEvent(HiveEventBase e, Actor actor, SendParameters sendParameters)

I don't know what to use for sendParameters, specifically for the channelId. Would it work if I just pass new SendParameters()?

Can you also elaborate what the channel id is used for? I'm really curious.

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    edited February 2017
    Options
    Hi @johnny_tictoc,

    Good questions!

    You are safe to use new SendParameters() most of the time.
    In rooms you can have multiple channels in each one you can exchange messages separately. Think of it as a tunnel of communication.
    This feature is not used in most cases, so by default all messages go through channel 0.
    Our wise @chvetsov can give you more details if you need them!
  • Thanks @JohnTube. In what cases would I use a channel other than 0?
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited March 2017
    Options
    Hi @johnny_tictoc,

    I was cleaning up some old docs and I found out something about the Channel parameter you were asking about:

    You can use different channels to group and prioritize events you are
    sending. We'll illustrate this functionality in a small example: Let's
    say you are using channel 1 to send relevant information about the
    position of players. You enabled reliable UDP in your game, because you
    need the extra reliability in the type of game you are envisioning. At
    some point channel 1 gets crowded by many messages because some players
    got delay and have a bad connection with a noticeable amount of packet
    loss, so a lot of messages have to be re-send. If you would now enqueue
    another important event (like the end of round), it might take some time
    for it to be acknowledged since the clients are still busy receiving all
    the position updates from channel 1. So if you dispatch an event now
    with channelId 0 it will take precedence over all the other queued
    messages. By making smart use of this feature you can raise the
    perceived responsiveness and ensure a correct flow of your game logic,
    even under mediocre connection conditions.


    In C# SDKs, you can find it in RaiseEventOptions.SequenceChannel it used to be named ChannelId.