Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:47 pm
by Brendan Doolan >> Wed, 12 Nov 2003 10:58:56 GMT
Dave,
The Jade feature called Notifications is the way to do this. And easy too. It may pay to ask yourself if you really need to know that a particular user is logged on and tell that user specifically , or do you just want to tell "anyone who may be interested". Very often it is the latter and then it is even simpler.
1. Define the object you are going to do the event on. This object must be visible to both the process causing the event and the interested party. Let's suppose this object is a persistent customer (cust)
2. The interested party (in your case the user you want to show popup box to) then does something like
rcvr.beginNotification(cust, eventNum, Response_Continuous, 0); where rcvr is often a form but can be any object. However, the userNotify or sysNotify event must be defined on the class of the rcvr object. This line needs to be done only once, for example in the load event of a form. Note that the event method is called userNotify (sysNotify) for Window subclasses but is called userNotification (sysNotification) for other classes. This is a necessary quirk due to the fact that a) controls on a form can be cloned and b) Jade does not support different parameters for overloaded methods.
3. When you want to communicate with interested parties, you do a
cust.causeEvent(eventNum, true, <info>);
where <info> can by anything, including null.
Jade will then send a windows message (a notification) to all interested parties ie. only those who called the method in 2 with the appropriate parameters.
The real beauty of this is that that you (the causer of the event) don't need to know who has declared an interest, if they are running etc.
If you do have to send a message to a specific user, often the best way of doing this is to get a reference to that user's Process object. A persistent instance of the process class is created by Jade for each user on the system. Then that user will do step 2 above but use process (the Jade keyword) instead of cust. You then can do step 3 but using the other user's process object instead of cust. Note that you should set an exception handler before step 3 in case the other user has signed off since, in that case, his process object will have been deleted by Jade so your reference will be to an invalid object. You will probably want to pass information via the third parameter (userInfo) in the causeEvent method.
Using the powerful feature of notifications allows you to let Jade do most of the hard work for you.
Brendan