NetworkBehaviour [Command] method is not executed on the server.

Hi, I’m developing a project that involves a server and multiple clients.
A Player prefab has a custom NetworkBehaviour that includes [Command] methods like this :

public class Player : NetworkBehaviour {
	[SerializeField] Renderer rPlayer;
	[SerializeField] PlayerAvatar avatar;

	[Header("Synchronized network variables")]
	[SerializeField] bool isAiming;
	public bool IsAiming{get{return isAiming;}}

	GameManager gm;
	// Use this for initialization
	void Start () {
		if(isLocalPlayer){
			gm = FindObjectOfType<GameManager>();
			gm.VuforiaARCamera.position = transform.position;
			transform.SetParent(gm.VuforiaARCamera);
			transform.localRotation = Quaternion.identity;

			NerfTrackableEventHandler[] trackables = FindObjectsOfType<NerfTrackableEventHandler>();
			for (int i = 0; i < trackables.Length; i++)
			{
				trackables*.onTrackingFound.AddListener(CmdOnTrackingFound);*

_ trackables*.onTrackingLost.AddListener(CmdOnTrackingLost);_
_
}_
_
}_
_
}*_

* // Update is called once per frame*
* void Update () {*
* if(isServer){*
* if(avatar != null){*
* avatar.SetDestination(transform.position);*
* }*
* }*
* }*

* void OnDestroy(){*
* Destroy(avatar.gameObject);*
* }*

* //--------- Vuforia event handler ----------//*
* [Command]*
* void CmdOnTrackingFound(){*
* Debug.Log(“target detected.”);*
* isAiming = true;*
* }*
* [Command]*
* void CmdOnTrackingLost(){*
* Debug.Log(“Target lost”);*
* isAiming = false;*
* }*

* //---------- Network methods -----------//*
* public override void OnStartClient()*
* {*
* base.OnStartClient();*
* }*

* public override void OnStartServer()*
* {*
* base.OnStartServer();*
* gm = FindObjectOfType();*
* avatar = gm.SpawnAvatar(0);*
* avatar.SetPlayerInstance(this);*
* }*
}
Those methods can only be called from the client, since the tracking is done by Vuforia on the client.
When I play it on the device the [Command] methods are called when the client found/lost a target, but the player instance on the server does nothing. the boolean isAiming isn’t changed even if the client changes the value.
The debug messages appear on XCode debug console(client), not on the Unity Editor console(server).
Am I doing something wrong??
I added the NetworkManager code here :
public class MyNetworkManager : NetworkManager {
* [Header(“NerfAR settings”)]*
* [SerializeField] bool isServer = true;*
* [SerializeField] GameManager gm;*

* public bool IsServer{*
* get{return isServer;}*
* set{*
* StopServer();*
* StopClient();*
* isServer = value;*
* }*
* }*

* void Reset(){*
* gm = GetComponent();*
* }*

* void Start(){*
* connectionConfig.NetworkDropThreshold = 90;*

* LoadNetworkSettings();*
* #if UNITY_STANDALONE || UNITY_EDITOR*
* StartServer();*
* #else*
* StartClient();*
* #endif*
* }*

* public string FindMyIP(){*
* Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, 0);*
* socket.Connect(“10.0.2.4”, 65530);*
* IPEndPoint endPoint = socket.LocalEndPoint as IPEndPoint;*
* string addr = endPoint.Address.ToString();*
* socket.Disconnect(true);*
* return addr;*

* }*

* #region SERVER*
* public override void OnStartServer()*
* {*
* if(isNetworkActive) StopServer(); // prevent socket exception*

* base.OnStartServer();*
* Debug.Log(“Starting server…”);*
* SaveNetworkSettings();*
* isServer = true;*
* StartCoroutine(DelayedServerStarted());*
* }*
* IEnumerator DelayedServerStarted(){*
* yield return new WaitForEndOfFrame();*
* yield return new WaitForEndOfFrame();*
* gm.OnServerStarted();*
* }*
* public override void OnStopServer()*
* {*
* base.OnStopServer();*
* Debug.Log(“OnStopServer”);*
* gm.OnServerStopped();*
* // Find and force destroy any player gameobjects*
* NetworkIdentity[] netIDs = FindObjectsOfType();*
* for(int i=0 ; i<netIDs.Length ; i++){*
_ Destroy(netIDs*.gameObject);
}*_

* System.GC.Collect();*
* }*

* public override void OnServerDisconnect(NetworkConnection conn)*
* {*
* base.OnServerDisconnect(conn);*
* Debug.Log("A client disconnected : ");*
* }*

* public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId)*
* {*
* base.OnServerAddPlayer(conn, playerControllerId);*
* Debug.Log(“A player has connected to the server.”);*
* //TODO send arena data to client*
* gm.OnServerAddPlayer();*
* }*
* #endregion*

* #region CLIENT*
* public override void OnStartClient(NetworkClient client)*
* {*
* base.OnStartClient(client);*
* Debug.Log(“Starting client…”);*
* isServer = false;*
* gm.OnClientStarted();*

* }*

* public override void OnStopClient()*
* {*
* base.OnStopClient();*
* Debug.Log(“OnStopClient”);*
* if(!isServer) gm.OnClientStopped(); //FIXME startServerOnly also calls StopClient() when StopServer().*
* }*

* public override void OnClientConnect(NetworkConnection conn)*
* {*
* base.OnClientConnect(conn);*
* Debug.Log(“Connected to the server!
Saving network settings…”);*

* gm.OnClientConnected();*
* // save current server ip for future use*
* SaveNetworkSettings();*
* //TODO send current arena data to client. Update arena;*

* }*

* public override void OnClientDisconnect(NetworkConnection conn)*
* {*
* base.OnClientDisconnect(conn);*
* Debug.Log(“disconnected”);*
* gm.OnClientDisconnected();*
* //StopClient();*

* }*
* #endregion*

* #region Load_Save_Network_Settings*
* string netConfigFilePath;*
* NetworkSettings savedData;*
* public NetworkSettings NetConfigData{*
* get{return savedData;}*
* set{savedData = value;}*
* }*
* bool LoadNetworkSettings(){*
* #if UNITY_EDITOR || UNITY_STANDALONE*
* netConfigFilePath = Application.dataPath + “/network.config”;*
* #else*
* netConfigFilePath = Application.persistentDataPath + “/network.config”;*
* #endif*

* if(!File.Exists(netConfigFilePath)){*
* Debug.LogWarning(“Network setting not found.
Use default settings…”);*

* gm.LoadNetworkSettings();*
* return false;*
* }*
* BinaryFormatter formatter = new BinaryFormatter();*
* FileStream fs = File.Open(netConfigFilePath, FileMode.Open);*
* try{*
* savedData = (NetworkSettings)formatter.Deserialize(fs);*
* networkAddress = savedData.networkAddress;*
* networkPort = savedData.networkPort;*
* isServer = savedData.isServer;*
* }catch (System.Exception e){*
* Debug.LogWarning(e+"
Network settings are corrupted!
Use default settings…");*

* fs.Close();*
* return false;*
* }*
* fs.Close();*
* Debug.Log(“Successfully loaded network settings.”);*
* gm.LoadNetworkSettings();*
* return true;*
* }*
* void SaveNetworkSettings(){*
* savedData = new NetworkSettings();*
* savedData.networkAddress = networkAddress;*
* savedData.networkPort = networkPort;*
* savedData.isServer = isServer;*

* BinaryFormatter formatter = new BinaryFormatter();*
* FileStream fs = File.Create(netConfigFilePath);*
* formatter.Serialize(fs,savedData);*
* fs.Close();*

* Debug.Log("Network settings have been saved to :
" + netConfigFilePath);*

* }*

* [System.Serializable]*
* public class NetworkSettings{*
* public string networkAddress;*
* public int networkPort;*
* public bool isServer;*
* }*
* #endregion*
}

Found the issue. The EventHandlers are only invoked on the client so the method isn’t called on the server. I changed like this :

//--------- Vuforia event handler ----------//
	[Client]
	void CmdOnTrackingFound(){
		//Debug.Log("target detected.");
		isAiming = true;
		CmdSetIsAiming(true);
	}
	[Client]
	void CmdOnTrackingLost(){
		//Debug.Log("Target lost");
		isAiming = false;
		CmdSetIsAiming(false);
	}

	[Command]
	void CmdSetIsAiming(bool b){
		Debug.Log("IsAiming : " + b);
		isAiming = b;
	}

And it works fine.