Given the following code on Uniface 9.4, what should be expected to happen?
CLIENT_FORM; Form so running on the client variables string vString endvariables newinstance ?REMOTE_1?, ?myRemote1? activate ?myRemote1?.setText(?Text From CLIENT_FRM?) newinstance ?REMOTE_2?, ?myRemote2? activate ?myRemote2?.getText(vString) message/info vString
REMOTE_1; a Service running remotely operation setText Params String pString : IN endParams newinstance ?REMOTE_2?, ?myRemote2? activate ?myRemote2?.SetText(pString) end
REMOTE_2; a Service running remotely operation init $MY_TEXT$ = ?Set in init? end operation setText Params String $MY_TEXT$ : IN endParams end operation getText params string $MY_TEXT$ : OUT endParams end
So to the questions:
- What should the activate of ?myRemote2?.GetText return?
?Set in init?
- Should both the instances created by CLIENT_FORM be created on the same userver?
If the userver is defined as exclusive then they will be on the same userver, if the uservers are shared between multiple clients then the second newinstance will be created on the oldest userver free at the time.
- If both instances are created on the same server why doesn?t ?myRemote2?.GetText return ?Text From CLIENT_FRM?
The scope of an instance is only within the context (client or userver) it was created. Even though both instances of REMOTE_2 are named myRemote2 (one created by CLIENT_FORM and the other by REMOTE_1) they are created in different contexts so will be isolated from one another. If this wasn?t the case there would be some very hard to diagnose bugs.
- Can I directly access to the instance of REMOTE_2 created by REMOTE_1 from within CLIENT_FORM.
Yes. A handle to myRemote2 can be obtained from within myRemote1 and passed back to the client. This handle can then be used to gain access to the existing remote instance.
- Should the code from REMOTE_1 and REMOTE_2 be visible in the clients debugger?
No. To debug code running on a userver you must attach a separate debugger instance to the userver. Whist debugging an application it is a good idea to use the /max=1 userver option so the application will not be tempted to start off new userver sessions and you can be sure to see all the calls in the debugger. There are a few youtube.com/unifacesme videos which demonstrate how to do this.