mina-sshd icon indicating copy to clipboard operation
mina-sshd copied to clipboard

Handle concurrent clients implicitly within the SFTP server EventListener

Open code-blooded245 opened this issue 1 year ago • 1 comments

Description

I need to handle multiple users and multiple commands from each user. For example multiple clients are executing put command to the SFTP server, in this case, I want to read the data in the SFTPEventListener class and do some processing. But I saw that the class instance is shared amongst multiple users and multiple user sessions, due to which I am not able maintain any state inside the SFTPEventListener. Although I can write my own implementation to handle this scenario but it would have been better if there was an implicit handle given in the library.

Motivation

By adding this, concurrent user requests can be implicitly handled in the library.

Alternatives considered

No response

Additional context

No response

code-blooded245 avatar Jan 08 '24 08:01 code-blooded245

All the methods in SftpEventListener take the ServerSession as an argument. It should thus be possible to maintain per-session state in the listener. Either maintain a map per session (and register a listener on the session to remove items from the map when a session closes), or add whatever per-session data you want to maintain as an attribute on the session object. Wouldn't that work for your use case?

tomaswolf avatar Jan 08 '24 12:01 tomaswolf