Jump to content
Sign in to follow this  
Hatchet_Harry

PublicVariableServer + EH: How is A3 processing it?

Recommended Posts

Hello there,

again i have a general design question.

We got the following idea:

We want to use publicVariableServer to process client informations, which are needed for some server tasks.

Now we discussed the command itself and there is one point unclear:

When i send an information with publicVariableServer to the server and handle it with an publicVariableEventhandler: Is it being processed as queue or is overwriting existing data?

The main problem:

Is 2 clients are updating the variable at the same time, it could happen that client 2 overwrites the data from client 1.

Client 1 would not be able to track it and i would have to send additional informations (double check if the server got the information). This costs performance, which i dont want to waste.

The Backup solution would be:

Remote execute a whitelisted serverside script with manipulation detection, which is just adding values to a array. The array is being used as working queue for the serverside tasks.

I would be able to track the changes and to involve headless clients easily if i want.

Back to the main question:

Is it being processed as queue or not? :386:

Regards

Dirk

:thanx:

Share this post


Link to post
Share on other sites

from what I understand about your problem and my knowledge, it simply updates the data on that client that catches the var (which in your case I'd assume would be everyone since publicVariable broadcasts to all), it will update that data on all machines if theres no way to tell which machine was supposed to receive that info. no other clients get the data overwritten if you had all clients check to see if a player id (for example) that was attached in the array of data returned matched theirs or not. if it matches then overwrite data, otherwise simply throw it away. You could make another function to force all clients to update their data as well.

Share this post


Link to post
Share on other sites

The value of the variable itself will be overwritten each time a client invokes the EH; receiving a broadcast new value is what fires the EH in the first place. Even if two clients were to attempt broadcasting a variable change simultaneously, though, I am 99% sure that the EH would fire twice, and each time it fires, you're going to be able to get the value uniquely set in each instance by using "_this select 1" within the EH code.

Edited by ST_Dux

Share this post


Link to post
Share on other sites

Hello Dux,

thanks for widening my view on the issue.

I was really focussed on the writing process and forgot the eventhandler itself!

For sure: The eventhanndler is being queued.

Client:

	708	19:59:36 "862.343"
709	19:59:36 "464.777"
710	19:59:36 "392.713"

Server:

	486	19:59:36 "Got a command and will wait for 5 seconds"
487	19:59:36 "Got a command and will wait for 5 seconds"
488	19:59:36 "Got a command and will wait for 5 seconds"
489	19:59:41 ["Now i show it",464.777]
490	19:59:41 [[464.777,23.163]]
491	19:59:41 ["Now i show it",392.713]
492	19:59:41 [[464.777,23.163],[392.713,23.163]]
493	19:59:41 ["Now i show it",862.343]
494	19:59:41 [[464.777,23.163],[392.713,23.163],[862.343,23.163]]

The execution is a little bit confusing, but he is doing it mostly like expected.

Client:

player addAction ["Send_Pubvar",
	{
		dummyRandon = random 1000;
		publicVariableServer "dummyRandon";
		player globalChat str dummyRandon;
		diag_log str dummyRandon;

		dummyRandon = random 1000;
		publicVariableServer "dummyRandon";
		player globalChat str dummyRandon;
		diag_log str dummyRandon;

		dummyRandon = random 1000;
		publicVariableServer "dummyRandon";
		player globalChat str dummyRandon;
		diag_log str dummyRandon;
	}
];

Server:

dummyArray = [];

"dummyRandon" addPublicVariableEventHandler {
	0 = _this spawn armajunkies_fnc_test;
};

//------ the function

#define __filename "fn_test.sqf"

_serverVar = _this select 1;
diag_log "Got a command and will wait for 5 seconds";
uisleep 5;
dummyArray pushBack [_serverVar, time];
diag_log ["Now i show it", _serverVar];
diag_log dummyArray;

He is ignoring the uiSleep, which drives me nuts. However...

But the test shows:

  • He is executing all commands
  • He mixes the incoming packets a little bit (i cant that if it is the order he is sending them, or he is recieving them)
  • For some reason uisleep and sleep are being ignored in PVEH, even if it is a spawned script

I hope the these findings are helping somebody else too.

Edited by Hatchet_Harry
typo

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×