How should I stop Apache Mina Ftp Server Listeners while connectivity state change in Android Studio java

两盒软妹~` 提交于 2020-07-03 12:55:12

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!