本文整理匯總了Java中fi.iki.elonen.NanoHTTPD.IHTTPSession方法的典型用法代碼示例。如果您正苦於以下問題:Java NanoHTTPD.IHTTPSession方法的具體用法?Java NanoHTTPD.IHTTPSession怎麽用?Java NanoHTTPD.IHTTPSession使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類fi.iki.elonen.NanoHTTPD
的用法示例。
在下文中一共展示了NanoHTTPD.IHTTPSession方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: get
import fi.iki.elonen.NanoHTTPD; //導入方法依賴的package包/類
@Override
public NanoHTTPD.Response get(RouterNanoHTTPD.UriResource uriResource, Map<String, String> urlParams, NanoHTTPD.IHTTPSession session) {
String sessionId = urlParams.get("sessionId");
try {
UiDevice mDevice = Elements.getGlobal().getmDevice();
Integer width = mDevice.getDisplayWidth();
Integer height = mDevice.getDisplayHeight();
JSONObject size = new JSONObject();
size.put("width", width);
size.put("height", height);
return NanoHTTPD.newFixedLengthResponse(getStatus(), getMimeType(), new Response(size, sessionId).toString());
} catch(Exception e) {
return NanoHTTPD.newFixedLengthResponse(getStatus(), getMimeType(), new Response(Status.UnknownError, sessionId).toString());
}
}
示例2: get
import fi.iki.elonen.NanoHTTPD; //導入方法依賴的package包/類
@Override
public NanoHTTPD.Response get(RouterNanoHTTPD.UriResource uriResource, Map<String, String> urlParams, NanoHTTPD.IHTTPSession session) {
String sessionId = urlParams.get("sessionId");
String elementId = urlParams.get("elementId");
try {
Element el = Elements.getGlobal().getElement(elementId);
final Rect rect = el.element.getVisibleBounds();
JSONObject res = new JSONObject();
res.put("x", rect.left);
res.put("y", rect.top);
res.put("height", rect.height());
res.put("width", rect.width());
return NanoHTTPD.newFixedLengthResponse(getStatus(), getMimeType(), new Response(res, sessionId).toString());
} catch (final Exception e) {
return NanoHTTPD.newFixedLengthResponse(getStatus(), getMimeType(), new Response(Status.UnknownError, sessionId).toString());
}
}
示例3: isRequestFile
import fi.iki.elonen.NanoHTTPD; //導入方法依賴的package包/類
/**
* 判斷請求是否是下載文件
* @param session
* @return
*/
public static boolean isRequestFile(NanoHTTPD.IHTTPSession session){
String uri = session.getUri(); // 獲取請求連接,範例:/xxx/yyy/zz.doc
String ext = getExt(uri);
if(ext == null){
return false;
}
if(NanoHTTPD.mimeTypes().containsKey(ext)){
return true;
}
return false;
}
示例4: serveOrCatch
import fi.iki.elonen.NanoHTTPD; //導入方法依賴的package包/類
public NanoHTTPD.Response serveOrCatch(NanoHttpdServer server, NanoHTTPD.IHTTPSession session) throws Exception {
switch (session.getMethod()) {
case GET:
return get.serve(server, session);
case PUT:
return put.serve(server, session);
default:
NanoMaven.getLogger().error("Unknown method: " + session.getUri());
return NanoHTTPD.newFixedLengthResponse(Status.NOT_FOUND, NanoHTTPD.MIME_HTML, "Unknown method");
}
}
示例5: GameSocket
import fi.iki.elonen.NanoHTTPD; //導入方法依賴的package包/類
public GameSocket(NanoHTTPD.IHTTPSession handshakeRequest, GameDetails gameDetails, Path workingDir) {
super(handshakeRequest);
this.gameDetails = gameDetails;
this.workingDir = workingDir;
}
示例6: handle
import fi.iki.elonen.NanoHTTPD; //導入方法依賴的package包/類
public String handle(NanoHTTPD.IHTTPSession session) {
String uri = session.getUri();
Map<String, String> parms = session.getParms();
Map<String,String> headers = session.getHeaders();
String ret = "{\"error\":\"invalid api call\"}";
Log.d(Utils.APP_IDENTIFIER, "API -> handle URI=".concat(uri));
boolean validUser = validateUser(headers);
if (!validUser){
return "{\"validauth\":\"false\"}";
}
switch (uri) {
/*IP:PORT/sms/threads*/
case ("/sms/threads"):
ret = getSMSThreads();
break;
/*IP:PORT/sms/thread?threadid=XX*/
/*IP:PORT/sms/thread?address=XX*/
case ("/sms/thread"):
ret = getSMSThread(parms);
//markSMSRead(parms);
break;
/*IP:PORT/sms/unread*/
/*IP:PORT/sms/unread?threadid=XX*/
case ("/sms/unread"):
ret = getSMSUnread(parms);
break;
/*IP:PORT/sms/markread?threadid=XX*/
case ("/sms/markread"):
ret = markSMSRead(parms);
break;
/*IP:PORT/sms/send?address=XXXXXXXXX&content=XXDDXX*/
case ("/sms/send"):
ret = sendSMS(parms);
break;
case ("/sms/send/status"):
ret = sentSmsStatus();
break;
/*IP:PORT/contacts*/
case ("/contacts"):
ret = getContacts();
break;
/*IP:PORT/contact/get?id=XXX*/
/*IP:PORT/contact/get?address=XXX*/
case ("/contact/get"):
ret = getContact(parms);
break;
//if we got here we have a valid session
case ("/auth"):
ret = "{\"validauth\":\"true\"}";
break;
}
return ret;
}
示例7: get
import fi.iki.elonen.NanoHTTPD; //導入方法依賴的package包/類
@Override
public NanoHTTPD.Response get(RouterNanoHTTPD.UriResource uriResource, Map<String, String> urlParams, NanoHTTPD.IHTTPSession session) {
String sessionId = urlParams.get("sessionId");
return NanoHTTPD.newFixedLengthResponse(getStatus(), getMimeType(), new Response(Status.NoSuchElement, sessionId).toString());
}
示例8: Socket
import fi.iki.elonen.NanoHTTPD; //導入方法依賴的package包/類
Socket(@NonNull NanoHTTPD.IHTTPSession handshakeRequest,
@NonNull Controller controller) {
super(handshakeRequest);
mController = controller;
}
示例9: doJsonGet
import fi.iki.elonen.NanoHTTPD; //導入方法依賴的package包/類
protected Object doJsonGet(File rootDir, NanoHTTPD.IHTTPSession httpSession, Map<String, String> restParams, String unmappedParams) {
return HttpUtils.methodNotAllowedResponse();
}
示例10: doJsonDelete
import fi.iki.elonen.NanoHTTPD; //導入方法依賴的package包/類
protected Object doJsonDelete(File rootDir, NanoHTTPD.IHTTPSession httpSession, Map<String, String> restParams, String unmappedParams) {
return HttpUtils.methodNotAllowedResponse();
}
示例11: onRequest
import fi.iki.elonen.NanoHTTPD; //導入方法依賴的package包/類
void onRequest(NanoHTTPD.IHTTPSession session);