[Unet] How to Use SendBytesToPlayer?

Hey guys!

Trying to use the SendBytesToPlayer() to send a serialized class to a specific player, but i dont get how to trigger a function on the other side to receive the data? can’t see any example on the unity manual so i came here!

Need this:

  1. Choose a destination player/connection
  2. Choose an specific Network Channel Id

Am trying something like this, but idk what to do next?

	public void SendSocketMessage(GameObject playerObj) {

		CubeListMessage msg = new CubeListMessage();
		msg.resourcePosition = resourcePosition;
		msg.resourceRotation = resourceRotation;
		msg.resourceType = resourceType;
		msg.resourceColor = resourceColor;
		msg.resourceColor2 = resourceColor2;
		msg.resourceColor3 = resourceColor3;

		byte error;
		byte[] buffer = new byte[1024];
		Stream stream = new MemoryStream(buffer);
		BinaryFormatter formatter = new BinaryFormatter();
		formatter.Serialize(stream, msg);
		int bufferSize = 1024;
		NetworkServer.SendBytesToPlayer(playerObj,buffer, bufferSize, 1);


Use a network message instead: