Page 1 of 1

Methods that switch from Client to Server

Posted: Fri Aug 07, 2009 11:23 am
by ConvertFromOldNGs
by JADE Kid - Ray Hidayat >> Sat, 13 Jan 2001 6:03:01 GMT

I have a method. It has a reference to certain files. Now the files could be on either the server or the client.

Obviously, if I was going to create a database of what is in certain folders and do other operations I would want it to be server or client execution depending on the situation.

Do I need to write two methods that do the same thing, but have either client or server execution in its signature, or is there an easier way?

--
Ray Hidayat
JADE Kid - 2000
www.jadekids.com

Re: Methods that switch from Client to Server

Posted: Fri Aug 07, 2009 11:23 am
by ConvertFromOldNGs
by Abduhl >> Sat, 13 Jan 2001 6:47:05 GMT
Do I need to write two methods that do the same thing, but have either client or server execution in its signature, or is there an easier way?

In current releases you need to define two methods, that is separate clientExecution and a serverExecution versions. It would pay to implement a single jacket method that is called from each of the client and serverExecution methods. There is a proposal to allow a method's execution node to by dynamically sepcified at runtime; 'its all there, someone just has to write the code'.

Re: Methods that switch from Client to Server

Posted: Fri Aug 07, 2009 11:23 am
by ConvertFromOldNGs
by JADE Kid - Ray Hidayat >> Sat, 13 Jan 2001 8:52:22 GMT

Having two methods call another is a very good idea. I never thought of that.

--
Ray Hidayat
JADE Kid - 2000
www.jadekids.com

Re: Methods that switch from Client to Server

Posted: Fri Aug 07, 2009 11:23 am
by ConvertFromOldNGs
by Robert Barr >> Sun, 14 Jan 2001 20:39:25 GMT

I found that following to be a fairly elegant solution - you can write a number of methods with a 'selectable' processing node, but with a single copy of critical code.

Create subclasses of File (for example) as below.

File
|--ServerFile
|--ClientFile

Add your method (the one with the code) on the File class. Create jacket methods on the subclasses that specify the processing node (serverExecution or clientExecution).

If you know the processing node at development time, then you can create refs or vars of the appropriate class. If the processing node is unknown until runtime, you can use the "create ... as ..." construct.