问题
I have a serious issue, I can't stop the listeners while ConnectivityStateChanged happens by a simple broadcast receiver. So basically I'm trying to stop the FTP server then start it immediately if any Connectivity Change happens because Apache Mina doesn't support restart. But stop is working as well if there are no such ConnectivityStateChanged. and Listeners are stopped.
//Apache Mina FTP Server Stop() method
@Override
public void stop() {
Log.d(TAG, "stop###");
if (serverContext == null) {
// we have already been stopped, ignore
return;
}
Log.d(TAG, "stop: all listeners");
// stop all listeners
Map<String, Listener> listeners = serverContext.getListeners();
for (Listener listener : listeners.values()) {
Log.d(TAG, "stopping ..." + listener.getServerAddress() + " " + listener.isStopped());
listener.stop(); ////////////// INSPECTED LINE /////////////
Log.d(TAG, "stopped: " + listener.isStopped());
}
// destroy the Ftplet container
serverContext.getFtpletContainer().destroy();
// release server resources
if (serverContext != null) {
serverContext.dispose();
serverContext = null;
}
started = false;
Log.d(TAG, "stop: Server Stopped");
}
IF NEEDED I WILL GIVE MORE INFO. PLEASE HELP. THANK YOU.
来源:https://stackoverflow.com/questions/62234734/how-should-i-stop-apache-mina-ftp-server-listeners-while-connectivity-state-chan