send data to specefic client in photon server

Options
in new photon we have clientPeer instead of PeerBase. and in that we have connectionID instead of playerID.

so when new client connects I assign a new id to it. but how to send a data to that client with certain id?

Comments

  • Serphimera
    Options
    Hi @virtouso,

    you need some kind of dictionary where you store your client's on the server side so that you can later lookup to what connectionId you want to send data, use that to retrieve the specific client (class) and send the data you want to send to that client.
  • no1no
    Options
    In my server I have something like this in GameApplication.cs
    public readonly Dictionary<int, MasterClientPeer> ClientPeersOnMaster = new Dictionary<int, MasterClientPeer>();

    Whenever a new peer is initiated and authenticated I'd add it like this
    application.ClientPeersOnMaster.Add(this.UserId, this);
    And in OnDisconnect I'd add
    this.application.ClientPeersOnMaster.Remove(this.UserId);

    And when I need to send an event I'd do this
    application.ClientPeersOnMaster[id].SendEvent(eventData, new SendParameters());

    Hope it helps.