10 private LoadBalancingPeer loadBalancingPeer;
12 private static PhotonNetwork.EventCallback lastEventCallback;
20 this.loadBalancingPeer = loadBalancingPeer;
24 return loadBalancingPeer.RoundTripTime;
27 public void OpRaiseEvent(byte eventCode,
object message,
bool reliable,
int[] toPlayers) {
28 if (loadBalancingPeer.PeerState != ExitGames.Client.Photon.PeerStateValue.Connected) {
32 RaiseEventOptions eventOptions =
new RaiseEventOptions();
33 eventOptions.TargetActors = toPlayers;
35 loadBalancingPeer.OpRaiseEvent(eventCode, message, reliable, eventOptions);
39 if (lastEventCallback != null) {
40 PhotonNetwork.OnEventCall -= lastEventCallback;
43 lastEventCallback = delegate (byte eventCode,
object content,
int senderId) { onEventReceived(eventCode, content); };
44 PhotonNetwork.OnEventCall += lastEventCallback;
int RoundTripTime()
Returns the roundtrip time between local player and server.
void AddEventListener(OnEventReceived onEventReceived)
Adds an event listener to handle received custom events.
Truesync's ICommunicator implementation based on PUN.
TrueSync's communicator interface.
void OpRaiseEvent(byte eventCode, object message, bool reliable, int[] toPlayers)
Raises a custom event to be sent to all other players.