PDA

View Full Version : Process ID



Bidmaron
December 26th, 2010, 16:31
Is there some (undocumented) way in which to obtain the windows process id for fantasygrounds. I need to be able to distinguish between client invocations. But now that I'm thinking about it, I don't suppose the system will let more than one client run on a computer due to license limitations? In this case I don't need to safeguard against multiple client invocations for a ruleset mod I'm working on. Anyone know for sure?

Zeus
December 26th, 2010, 22:32
I am not sure about how to go about obtaining the fantasygrounds.exe process ID aside from using the usual Windows cmdline (tasklist, svchost) commands and ProcessManager windows. Perhaps someone else can offer some advice.

If on the other hand you want to determine between host and client sessions from within FGII's LUA script, you can use the in-built global package, User, specifically the function User.IsHost().

e.g.


function onInit()
local msg = {sender = "", font = "system"};

if User.IsHost() then
msg.text = "Running as Host"
else
msg.text = "Running as Client"
end

ChatManager.addMessage(msg);
end

Bidmaron
December 27th, 2010, 05:26
No, I just need to make sure there isn't more than one client running on the same computer. I don't think the software will let it happen (you are authorized to run one client along with your host to test your campaigns, but not more than that), but it's easy enough to test, I suppose.

StuartW
December 27th, 2010, 07:58
You *can* run more than one client if you are hosting (I've tested rulesets using this feature). Not sure if you are allowed otherwise.

Stuart

EDIT: In most cases, each client has a unique ID determined by their active PC, which you can establish using User.GetCurrentIdentity().

Bidmaron
December 27th, 2010, 13:41
hmm.... Thanks for the clarification, Stuart.

Bidmaron
December 27th, 2010, 17:14
OK, then. That implicitly means that any local clients share the same campaign database and cache file, modules, etc as the host. (obviously, they could activate modules [non-forced] separately, but they'd access the same campaign folder)

StuartW
December 27th, 2010, 21:07
Hmm, I think (but am not sure) that local clients use the cache, whereas the host uses the campaign db etc. JPG is better placed to advise than me ;)

Stuart

Bidmaron
December 27th, 2010, 21:09
That would make sense....

Moon Wizard
January 5th, 2011, 20:47
Yes, the host uses the campaign directory, and the client uses the cache directory.

Cheers,
JPG

Bidmaron
January 8th, 2011, 08:29
Great, thanks. But if a tester runs more than one client on a localhost kind of setup, they must then share the same cache directory and file. Can't really grok how that can work reliably.

StuartW
January 9th, 2011, 06:54
In my experience, testing using clients luanched from the host's machine *isn't* a reliable method. It may partly be due to the shared cache, but it also fails to simulate network lag, so client/client contention issues behave very differently. It's a bit of a bummer, specially when you are building rulesets etc, because some bugs only surface when you have 2+ real clients connected.

Back to the OP: the GetCurrentIdentity method isn't fully robust, because clients can release all their PCs and then don't have unique IDs.

Stuart