change position as whole object

hi there, i was learning socket.io and now im trying with colysues.
my state structure is something like that, e.q:

this.state = {
	players: {
		'someid1': {
			position: {
				x: 0,
				y: 0,
			},
			destinationPosition: {
				x: 0,
				y: 0,
			}
		}
	}
}

and then in my client in Unity i am clicking on ground for example in position (x:100, y:100) and send that to the server, then i want to change destinationPosition as whole object, x and y at once, is it possible with json-patch ?
Right now i have to change x and y separately and then in my client read that property again separately but i want to get them at once (i want to receive position = {x: 100, y: 100} object in my unity client).

Chers!

Hi @halome, welcome!

Usually you'll listen for a particular attribute coming from the server. You can see in the example project how it's being done:

You'd listen for your own properties, though, like:

room.Listen ("players/:id/destinationPosition/:axis", this.OnPlayerMove);

Hope this helps, let me know if you have other question.
Cheers!

Hi @endel

Thanks for your answer!

So i have to check what kind of attribute is this? X or Y ?

this is not actual code (its wrote right now so sorry for typos) but it would be somethink like that?

Player player = players [change.path ["id"]];
Navigator navigator = player.getNavigatorComponent();
Vector3 currentDestination = navigator.getCurrentDestination();

if(change.path ["axis"] == "x"){
		navigator.setDestination(new Vector3 (
			Convert.ToSingle (change.value), 0, currentDestination.z
		));
}
if(change.path ["axis"] == "y"){
		navigator.setDestination(new Vector3 (
			currentDestination.x, 0, Convert.ToSingle(change.value)
		);
}

@halome exactly!