當前位置: 首頁>>代碼示例>>Java>>正文


Java NanoHTTPD.IHTTPSession方法代碼示例

本文整理匯總了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());
    }
}
 
開發者ID:macacajs,項目名稱:UIAutomatorWD,代碼行數:16,代碼來源:WindowController.java

示例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());
    }
}
 
開發者ID:macacajs,項目名稱:UIAutomatorWD,代碼行數:18,代碼來源:ElementController.java

示例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;
}
 
開發者ID:dwdyoung,項目名稱:AndroidWeb,代碼行數:17,代碼來源:WebUtils.java

示例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");
    }
}
 
開發者ID:dzikoysk,項目名稱:NanoMaven,代碼行數:12,代碼來源:NanoRepositoryRouter.java

示例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;
}
 
開發者ID:adamkewley,項目名稱:textadventurer-server,代碼行數:6,代碼來源:GameSocket.java

示例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;
}
 
開發者ID:strang3quark,項目名稱:remotedroid,代碼行數:58,代碼來源:API.java

示例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());
}
 
開發者ID:macacajs,項目名稱:UIAutomatorWD,代碼行數:6,代碼來源:ExecuteController.java

示例8: Socket

import fi.iki.elonen.NanoHTTPD; //導入方法依賴的package包/類
Socket(@NonNull NanoHTTPD.IHTTPSession handshakeRequest,
       @NonNull Controller controller) {
    super(handshakeRequest);
    mController = controller;
}
 
開發者ID:kevalpatel2106,項目名稱:robo-car,代碼行數:6,代碼來源:Socket.java

示例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();
}
 
開發者ID:turt2live,項目名稱:matrix-embedded-federation,代碼行數:4,代碼來源:JSONServant.java

示例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();
}
 
開發者ID:turt2live,項目名稱:matrix-embedded-federation,代碼行數:4,代碼來源:JSONServant.java

示例11: onRequest

import fi.iki.elonen.NanoHTTPD; //導入方法依賴的package包/類
void onRequest(NanoHTTPD.IHTTPSession session); 
開發者ID:zugaldia,項目名稱:android-robocar,代碼行數:2,代碼來源:HTTPRequestListener.java


注:本文中的fi.iki.elonen.NanoHTTPD.IHTTPSession方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。