You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ftpserver-users@mina.apache.org by Zorgan <la...@gmail.com> on 2008/04/29 10:45:59 UTC

Why did the Connection class disappear ?

Hi,

I used to use the following code to stop the download for a specific client
:

List<Connection> connections =
ftpServer.getServerContext().getConnectionManager().getAllConnections();

for (Connection con : connections)
{

if(con.getSession().getClientAddress().toString().equals("/"+myClient.getAddress())
       &&
con.getSession().getUser().getName().equals(myClient.getFtpUser()))
    {
       // stop the download ...
    }
}

I just realized that the org.apache.ftpserver.listener.Connection class and
the getConnectionManager() of the FtpServerContext class were removed.

Does any body know how can I deal with these API changes ?

Re: Why did the Connection class disappear ?

Posted by Zorgan <la...@gmail.com>.
Thank you!
testing...

Re: Why did the Connection class disappear ?

Posted by Niklas Gustavsson <ni...@protocol7.com>.
On Tue, Apr 29, 2008 at 12:08 PM, Niklas Gustavsson
<ni...@protocol7.com> wrote:
>  However, as you noted there is currently no way of finding the active
>  sessions. How about we provide a method on the Listener:
>  List<FtpIoSession> getActiveSessions()

This change has now been commited, please try it out and see if it
fits your needs.

/niklas

Re: Why did the Connection class disappear ?

Posted by Niklas Gustavsson <ni...@protocol7.com>.
Hi

The reason for this class (and a whole lot of others) being removed is
that we now use MINA for this functionality, meaning we no longer need
to keep our own code.

However, as you noted there is currently no way of finding the active
sessions. How about we provide a method on the Listener:
List<FtpIoSession> getActiveSessions()

That way you could write your code like:

        Listener listener = ftpServer.getServerContext().getListener("default");
        List<FtpIoSession> sessions = listener.getActiveSessions();

        for (FtpIoSession session : sessions) {
            if(session.getRemoteAddress().toString().equals("/"+myClient.getAddress())
                    &&
                    session.getUser().getName().equals(myClient.getFtpUser())) {
                    // stop the download ...
            }
        }

Would that work for you?

/niklas


On Tue, Apr 29, 2008 at 10:45 AM, Zorgan <la...@gmail.com> wrote:
> Hi,
>
>  I used to use the following code to stop the download for a specific client
>  :
>
>  List<Connection> connections =
>  ftpServer.getServerContext().getConnectionManager().getAllConnections();
>
>  for (Connection con : connections)
>  {
>
>  if(con.getSession().getClientAddress().toString().equals("/"+myClient.getAddress())
>        &&
>  con.getSession().getUser().getName().equals(myClient.getFtpUser()))
>     {
>        // stop the download ...
>     }
>  }
>
>  I just realized that the org.apache.ftpserver.listener.Connection class and
>  the getConnectionManager() of the FtpServerContext class were removed.
>
>  Does any body know how can I deal with these API changes ?
>