Hi there,
I want know how to prevent opening multiple copies of same runtime solution if the user double clicks the runtime icon again.
I can think of this in two ways.
When the user double clicks the runtime solution icon the second time
1> It can directly goto the firstly opened solution without opening the second one.
2> It opens the second solution and then alert the user that a copy of the same solution was opened already.
I like both options.
Thanks for your suggestions
In most cases I’d assume if you open an application twice that you want to open it twice so I don’t think this should be the default behaviour. I regularly open multiple clients off the same server to run multiple solutions at once. A solution for you could be to use
application.setUserProperty(String name, String value)
to maintain a list of users/machines logged in and based on that info kick them out if they log in again.
If client and server are on the same network you can also change your shortcut to open a URL instead of the jnlp. If you open a URL that deeplinks to the solution and you are on a local network it will open the already running client.
http://<servoy_server_ip>/servoy-client/servoy_client.jnlp?solution=<solution>&method=<method>&argument=<args>
Thanks Jan for your reply,
Actually I want to prevent opening two instances of a runtime solution on the same machine not a real servoy client. (ie not the client/server one)
Do you have any advice for me for this?
Like Jan said you can set a property on the server when a solution is opened by a client.
application.setUserProperty(String name, String value)
You could set a value like the solutionname and IP of the client and then do a check for how many of the same properties are registered in the server.
I believe that is done with this:```
application.getClientCountForInfo(String name)
If it's more then 1 then the client has more than 1 client with the same solution open and you can give the user a message accordingly before closing the client.
These functions were introduced in Servoy 2.2 so they are fairly new.
See it as the equivalent of a web cookie but in this case stored on the server.
Hope this helps.
Ah, I missed the bit where you say that you are running Runtime. I don’t think it can be done with runtime but i shall investigate.
I should have read better also.
I guess you can ignore my last post.