Exemplo n.º 1
0
  @Override
  public FtpletResult onConnect(FtpSession session) throws FtpException, IOException {

    Log.i("xerrard", "建立新连接:" + session.getClientAddress());
    UserSession mSession =
        new UserSession(Const.DATA_TRANSFER_STATE_DEFAULT, session.getClientAddress(), 0);
    mSingleton.mUserSessionList.add(mSession); // 建立连接后加入用户列表

    return super.onConnect(session);
  }
Exemplo n.º 2
0
  @Override
  public FtpletResult onDisconnect(FtpSession session) throws FtpException, IOException {
    Log.i("xerrard", "连接关闭:" + session.getClientAddress());
    for (UserSession mSession : mSingleton.mUserSessionList) {
      if (mSession.inetSocketAddress.equals(session.getClientAddress())) {
        mSingleton.mUserSessionList.remove(mSession); // 关闭连接后从用户列表中移除
      }
    }

    return super.onDisconnect(session);
  }
Exemplo n.º 3
0
 @Override
 public FtpletResult onUploadEnd(FtpSession session, FtpRequest request)
     throws FtpException, IOException {
   // TODO Auto-generated method stub
   Log.i("xerrard", "onUploadEnd" + session.getClientAddress());
   mSingleton.DataTransferState = Const.DATA_TRANSFER_STATE_ED;
   for (int i = 0; i < mSingleton.mUserSessionList.size(); i++) {
     if (session.getClientAddress().equals(mSingleton.mUserSessionList.get(i).inetSocketAddress)) {
       mSingleton.mUserSessionList.get(i).dataTransferState =
           mSingleton.DataTransferState; // 发送完毕后置状态
     }
   }
   return super.onUploadEnd(session, request);
 }
Exemplo n.º 4
0
 @Override
 public FtpletResult onLogin(FtpSession session, FtpRequest request)
     throws FtpException, IOException {
   // TODO Auto-generated method stub
   Log.i("xerrard", "onLogin:" + session.getClientAddress());
   return super.onLogin(session, request);
 }
  /*
   * 上传完成时动作:通过spring容器发送事件消息
   *
   * @see
   * org.apache.ftpserver.ftplet.DefaultFtplet#onUploadEnd(org.apache.ftpserver
   * .ftplet.FtpSession, org.apache.ftpserver.ftplet.FtpRequest)
   */
  @Override
  public FtpletResult onUploadEnd(FtpSession session, FtpRequest request) {
    String username = session.getUser().getName();
    String input = session.getUser().getHomeDirectory() + "/" + request.getArgument();
    String homeDirectory = session.getUser().getHomeDirectory();
    /** 发送spring事件 */
    HashMap<String, String> map = new HashMap<String, String>();
    map.put("username", username);
    map.put("homeDirectory", homeDirectory);
    map.put("input", input);
    logger.debug(map);

    Message<String> message = MessageBuilder.withPayload("").copyHeaders(map).build();

    filePathChannel.send(message);

    return FtpletResult.DEFAULT;
  }