the server push client
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   zhebin_cong
Posted On:   Wednesday, March 31, 2004 12:35 AM

hello
i use the swing write the client-side console,but this client side console fuction not as normal,it don't receive info ACTIVATELY, it works as a monitor to superwise other computer(i call it server),the server push data to the client-side console,that means the swing client PASSIVATELY get info,one info item arrived,the one item is displayed on a table within the client console.
who can tell me,what's the better solution to my requirement,socket or rmi?and how?

thank you very much!

Re: the server push client

Posted By:   Fabien_Toral  
Posted On:   Thursday, April 8, 2004 09:08 AM

Hi,

I think you need to implement something like the Observer pattern through an RMI bridge.



I'm actually working on a project whose GUI need to be notified from the server on data state changing.



I've tried to implement warping of java.util.Observer/Observable classes as describe in the Sun RMI FAQ.
But this java implementation of the observer pattern has too lacks to be correctly wrapped.

So i'm coding myself an RMI callback based on events like in swing. My work is based on David Grimshaw's course on RMI Callback.



See here for another implementation of the Observer pattern, it also discuss on the lacks of the implementation in the Java API.



Hope this helps.



Fabien

Re: the server push client

Posted By:   Genady_Beryozkin  
Posted On:   Thursday, April 8, 2004 07:57 AM

You can use both methods, with the rule of thumb being how complex your protocol is. If all you need is to pass strings from one site to another - use sockets.
If you need some kind of complex bidirectional protocol, RMI is good for you.

You should also recall that RMI calls are performed in a separate thread, so you must use SwingUtilities.invokeLater() methods to update your Swing components.

Genady Beryozkin,

Author of the RMI Plugin for Eclipse

http://www.genady.net/rmi/

About | Sitemap | Contact