koush / AndroidAsync

Asynchronous socket, http(s) (client+server) and websocket library for android. Based on nio, not threads.
Other
7.52k stars 1.56k forks source link

How to use create a HttpServer and destory it. #687

Open Forever1Love opened 3 years ago

Forever1Love commented 3 years ago

hello,I am a learner of the AndroidAsync, I want to create a HttpServer on a activity ,while the activity is finished, the httpServer shoud be destoryed , I tried it , but When the activity is finished, the httpServer is alive , I can browse the url through my browse. activity the class extends  AsyncHttpServer

chenzuohua918 commented 3 years ago

I meat this problem too!

chenzuohua918 commented 3 years ago

I fix it by this: AsyncServer mAsyncServer = AsyncServer.getDefault(); AsyncHttpServer mServer = new AsyncHttpServer();

 public void start() {
        mServer.listen(mAsyncServer, port);
 }

 public void stop() {
        mServer.stop();
        mAsyncServer.stop();
 }
Forever1Love commented 3 years ago

Thank you very much.