From: mafor <nu...@jb...> - 2005-05-17 15:04:51
|
There is another way to solve but it requires some refactoring to move the ping handling to intermediate filter streams. In this way, even if the marshallers wraps the stream with an Object*Stream, the intermediate streams will manage the pings. Stream hierarchy: Raw*Stream -> Buffered*Stream -> Ping*Stream (-> Object*Stream) The PingOutputStream wraps the raw socket output stream and adds a thin layer of ping management. The PingOutputStream contains a timer that generates a ping at predefined intervals. The ping timer is reset every time some real data is written so a ping is only generated when needed. The logic for this is located within the write(int) method and is synchronized so no other data can be written during pings. Immediately after sending the ping the stream will try to read the responding pong packet. A corresponding PongInputStream similiarly wraps the raw socket input stream and adds a thin layer looking for the arrival of a ping packets. If a ping packet is received it immediately replies by sending back a pong packet. Otherwise the data is just forwarded as usual. Since the ping/pong packets are totally managed within the intermediate filter streams there is no need to issue a reset on the Object*Streams used by the marshallers. View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3878035#3878035 Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3878035 |