// Called when server receives a CreateTapMarkerMessage private void OnServerCreateTapMarkerHandler(NetworkMessage netMsg) { // Read the message CreateTapMarkerMessage createTapMarkerMessage = netMsg.ReadMessage <CreateTapMarkerMessage>(); // Retransmit this message to all other clients except the one who initially sent it, // since that client already creates a local tap marker on his own foreach (NetworkConnection connection in NetworkServer.connections) { if (connection == null || connection == netMsg.conn) { continue; } connection.Send(CreateTapMarkerMessage.kMessageType, createTapMarkerMessage); } foreach (NetworkConnection connection in NetworkServer.localConnections) { if (connection == null || connection == netMsg.conn) { continue; } connection.Send(CreateTapMarkerMessage.kMessageType, createTapMarkerMessage); } }
// Called when client receives a CreateTapMarkerMessage private void OnClientCreateTapMarkerHandler(NetworkMessage netMsg) { // Just instantiate a tap marker in the tap position CreateTapMarkerMessage createTapMarkerMessage = netMsg.ReadMessage <CreateTapMarkerMessage>(); Instantiate(TapMarkerPrefab, createTapMarkerMessage.Position, Quaternion.identity); }