move debugger to doric

This commit is contained in:
pengfei.zhou
2019-08-09 16:32:38 +08:00
parent 73b9d97e6d
commit 7f8d579c0f
7 changed files with 86 additions and 42 deletions

View File

@@ -1,40 +0,0 @@
package com.github.penfeizhou.doricdemo;
import android.content.Context;
import android.content.res.AssetManager;
import java.io.IOException;
import java.io.InputStream;
import fi.iki.elonen.NanoHTTPD;
/**
* @Description: com.github.penfeizhou.doricdemo
* @Author: pengfei.zhou
* @CreateDate: 2019-08-03
*/
public class LocalServer extends NanoHTTPD {
private final Context context;
public LocalServer(Context context, int port) {
super(port);
this.context = context;
}
@Override
public Response serve(IHTTPSession session) {
String url = session.getUri();
if (url.startsWith("/assets/")) {
String fileName = url.substring("/assets/".length());
AssetManager assetManager = context.getAssets();
try {
InputStream inputStream = assetManager.open(fileName);
return newFixedLengthResponse(Response.Status.OK, "text/plain", inputStream, inputStream.available());
} catch (IOException e) {
e.printStackTrace();
}
}
return newFixedLengthResponse(NanoHTTPD.Response.Status.OK, "text/html", "HelloWorld");
}
}

View File

@@ -7,6 +7,7 @@ import android.widget.FrameLayout;
import com.github.penfeizhou.doric.Doric;
import com.github.penfeizhou.doric.DoricContext;
import com.github.penfeizhou.doric.dev.LocalServer;
import com.github.penfeizhou.doric.utils.DoricUtils;
import com.github.pengfeizhou.jscore.JSONBuilder;
@@ -33,5 +34,4 @@ public class MainActivity extends AppCompatActivity {
e.printStackTrace();
}
}
}