Multiple client instances

Post your questions regarding using the Vault and Fortress API in your programs.

Moderator: SourceGear

Post Reply
smartbear
Posts: 38
Joined: Thu Jan 24, 2008 10:13 am
Contact:

Multiple client instances

Post by smartbear » Fri Apr 24, 2009 9:59 am

We can create multiple client instances, running ServerOperations.Login() after setting the client LoginOptions for each one. When we do, running ServerOperations.GetWorkingFolderAssignments() only returns folders corresponding to the first login session. I guess our second call to ServerOperations.Login() is really doing nothing and we really only have one login session/client instance.

Is there a way for us to use ServerOperations().GetWorkingFolderAssignments() and the various ServerOperations.ProcessCommandXXXX methods for multiple client instances? Would saving and restoring the current client instance with ServerOperations.client.get_ClientInstance() and ServerOperations.set_ClientInstance() work?

Eric

jeremy_sg
Posts: 1821
Joined: Thu Dec 18, 2003 11:39 am
Location: Sourcegear
Contact:

Re: Multiple client instances

Post by jeremy_sg » Fri Apr 24, 2009 2:28 pm

Yes, I think that if you always switch your clientinstances before you do things, you should be fine. Also, make sure that no two clientInstances are doing anything at once.
Subscribe to the Fortress/Vault blog

smartbear
Posts: 38
Joined: Thu Jan 24, 2008 10:13 am
Contact:

Re: Multiple client instances

Post by smartbear » Fri May 08, 2009 9:29 am

Jeremy,

Thanks, I was able to get this to work. This is what I had to do:

final ClientInstance ci = new ClientInstance();
ci.Init(VaultConnection.AccessLevelType.Client);
ServerOperations.client.set_ClientInstance(ci);
VaultLib.Brander.getInstance().setMode(connection.isFortressMode() ? Brander.Mode.FortressMode : Brander.Mode.VaultMode);
//set ServerOperations.client.LoginOptions here
ServerOperations.Login();
//save ServerOperations.client.get_ClientInstance() for later use with set_ClientInstance()
//note that this is not the ClientInstance constructed and set above, ServerOperations.Login() creates a new one

Eric

jeremy_sg
Posts: 1821
Joined: Thu Dec 18, 2003 11:39 am
Location: Sourcegear
Contact:

Re: Multiple client instances

Post by jeremy_sg » Fri May 08, 2009 9:31 am

Thanks for the update Eric. Let me know if you need anything else.
Subscribe to the Fortress/Vault blog

Post Reply