users@grizzly.java.net

Re: [ANN] Getting notified when client or server close the connection.

From: Survivant 00 <survivant00_at_gmail.com>
Date: Tue, 25 Nov 2008 09:01:48 -0500

I reopen the bug, but not sure if I did it correctly.

here what I have.


tcpSelectorHandler.setSelectionKeyHandler(new BaseSelectionKeyHandler(){

                   public void locallyClosed(SelectionKey key) {
                       s_logger.debug(key + " is being locally cancelled");
                   }

                   public void remotlyClosed(SelectionKey key) {
                       s_logger.debug(key + " is being remotly cancelled
(connection closed)");
                   }
                });

            f_controller.addSelectorHandler(tcpSelectorHandler);

if I open a telnet connection and close it, I won't be notify.

but I didn't use ConnectionCloseHandler.

Can I mix the 2 handlers ?




2008/11/24 Jeanfrancois Arcand <Jeanfrancois.Arcand_at_sun.com>

> Salut,
>
> I've added a new Handler for managing local and remote connection close.
> The new ConnectionCloseHandler[1] can be configured on any class that
> extends our BaseSelectionKeyHandler (like DefaultSelectionKeyHandler):
>
> SelectionKeyHandler skh = new DefaultSelectionKeyHandler();
> shk.setConnectionCloseHandler(new ConnectionCloseHandler() {
>
> public void locallyClosed(SelectionKey key) {
> logger.info(key + " is being locally cancelled");
> }
>
> public void remotlyClosed(SelectionKey key) {
> logger.fine(key + " is being remotly cancelled (connection
> closed)");
> }
> });
>
> controller.setSelectionKeyHandler(skh);
>
> Those two methods gets invoked when any of the following condition happens:
>
> 1. Any IOException occurs on I/O operations (read/write)
> 2. When the read() or write() operation return -1
>
> Please try it :-)
>
> A+
>
> -- Jeanfrancois
>
> [1]
> https://grizzly.dev.java.net/nonav/apidocs/com/sun/grizzly/util/ConnectionCloseHandler.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>
>