NanoHTTPD 服务

public class MyWebServer extends NanoHTTPD {
    private FaceEngine faceEngineWeb;
    private final static int PORT = 33445;
    private Context _mainContext;
    private static boolean isRun = false;
    HttpRequestUtil httpRequestUtil =new HttpRequestUtil();
    /* private String deviceKey = Myapp.getBaseData().getDeviceKey();
     private String passKey = Myapp.getBaseData().getPassKey();*/

    主构造函数,也用来启动http服务
    */
    public MyWebServer(Context context) throws IOException {
        super(PORT);
        _mainContext = context;
        start();
    }

    /*
    解析的主入口函数,所有请求从这里进,也从这里出
    */
    @Override
    public Response serve(IHTTPSession session) {
       
            return newFixedLengthResponse( "" );
      
    }
}

//调用

MyWebServer mywebserver = new MyWebServer(this);

//销毁

if (mywebserver != null) {
    mywebserver.closeAllConnections();
    mywebserver = null;
}

 

你可能感兴趣的:(Android,服务)