send data to specefic client in photon server
Options
virtouso
✭
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?
so when new client connects I assign a new id to it. but how to send a data to that client with certain id?
0
Comments
-
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.1 -
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 thisapplication.ClientPeersOnMaster.Add(this.UserId, this);
And in OnDisconnect I'd addthis.application.ClientPeersOnMaster.Remove(this.UserId);
And when I need to send an event I'd do thisapplication.ClientPeersOnMaster[id].SendEvent(eventData, new SendParameters());
Hope it helps.1