2 Replies Latest reply on Nov 8, 2006 1:07 PM by sarbu

    Procedure to cleanly remove the listener?

    sarbu

      hi all,

      I have a client connector to communicate to my peer. I have a listener registered in case the communication with the peer is lost. When I reboot the peer, the handleConnectionException API in the client side is invoked. In this, I disconnect the client:

      client.disconnect();

      Would this be sufficient? The reason I am asking this question is because, even after above call is done, I see the handleConnectionException method is called for every ping period.

      I noticed that there is another method in client object - removeConnectionListener. I am making the code changes in the handler to call this method as well.

      Is there anything else I should be doing to make sure that the listener is called only once when the connection is lost? It would be of great help if anyone could post the steps that have to be done for handling this scenario gracefully.

      Thanks
      Saravanan

        • 1. Re: Procedure to cleanly remove the listener?

          Sounds like you are talking about use of Client.addConnectionListener(ConnectionListener listener, int pingPeriod). Fom looking at latest remoting code base, after the connection notifier is fired so that all the ConnectionListeners are notified, the connection notifier is stopped, so should not receive any further notifications. Also, if call Client.removeConnectionListener(ConnectionListener listener) and is the only registered listener, will then also stop the connection notifier.

          • 2. Re: Procedure to cleanly remove the listener?
            sarbu

            Hi Tom,

            Yes, I am talking about Client.addConnectionListener(ConnectionListener listener, int pingPeriod).

            The first time I get a connection lost notification event, I call disconnect on the client connector. I have noticed that if I do not remove the listener explicitly using the removeListener(listener) API I keep getting the notification for the connection lost. I just wanted to bring this up in case this has not been addressed yet.

            Please note that I am using 1.4.0 version. We are far ahead in the current release that we cannot upgrade (but definitely upgrade is the priority in the next release).

            Saravanan