主頁 > 移動端開發 > “NanoHttpd微型服務器”使用及原始碼閱讀

“NanoHttpd微型服務器”使用及原始碼閱讀

2020-09-13 23:33:21 移動端開發

“NanoHttpd微型服務器”使用及原始碼閱讀

NanoHttpd僅有一個Java檔案的微型Http服務器實作,其方便嵌入式設備(例如:Android設備)中啟動一個本地服務器,接收客戶端本地部分請求;應用場景也非常廣泛,例如:本地代理方式播放m3u8視頻、本地代理方式加載一些加密秘鑰等,

這里分三部分學習一個這個NanoHttpd:

  • 了解官方對NanoHttpd描述定義
  • 舉例NanoHttpd在Android上的使用(Android本地代理,播放Sdcard中的m3u8視頻)
  • 分析原始碼實作

NanoHttpd GitHub地址:https://github.com/NanoHttpd/nanohttpd

一、NanoHttpd 官方描述

Tiny, easily embeddable HTTP server in Java.
微小的,輕量級適合嵌入式設備的Java Http服務器;
NanoHTTPD is a light-weight HTTP server designed for embedding in other applications, released under a Modified BSD licence.
NanoHTTPD是一個輕量級的、為嵌入式設備應用設計的HTTP服務器,遵循修訂后的BSD許可協議,

核心功能描述:

  • Only one Java file, providing HTTP 1.1 support.
    僅一個Java檔案,支持Http 1.1
  • No fixed config files, logging, authorization etc. (Implement by yourself if you need them. Errors are passed to java.util.logging, though.)
    沒有固定的組態檔、日志系統、授權等等(如果你有需要需自己實作,工程中的日志輸出,通過java.util.logging實作的)
  • Support for HTTPS (SSL).
    支持Https
  • Basic support for cookies.
    支持cookies
  • Supports parameter parsing of GET and POST methods.
    支持POST和GET 引數請求
  • Some built-in support for HEAD, POST and DELETE requests. You can easily implement/customize any HTTP method, though.
    內置支持HEAD、POST、DELETE請求,你可以方便的實作或自定義任何HTTP方法請求,
  • Supports file upload. Uses memory for small uploads, temp files for large ones.
    支持檔案上傳,小檔案上傳使用記憶體快取,大檔案使用臨時檔案快取,
  • Never caches anything.
    不快取任何內容
  • Does not limit bandwidth, request time or simultaneous connections by default.
  • 默認不限制帶寬、請求時間 和 最大請求量
  • All header names are converted to lower case so they don't vary between browsers/clients.
    所有Header 名都被轉換為小寫,因此不會因客戶端或瀏覽器的不同而有所差別
  • Persistent connections (Connection "keep-alive") support allowing multiple requests to be served over a single socket connection.
    支持一個socket連接服務多個長連接請求,

二、NanoHttpd在Android上的使用舉例

為了學習NanoHttpd,做了一個簡單Demo “Android 本地代理方式播放 Sdcard中的m3u8視頻”:
Android 本地代理方式播放 Sdcard中的m3u8視頻
https://github.com/AndroidAppCodeDemo/Android_LocalM3u8Server

實作效果圖:

enter description here

注:

  • Android 本地代理方式播放 Sdcard中的m3u8視頻(使用的NanoHttpd 版本為 2.3.1
    NanoHttpd 2.3.1版本下載
    https://github.com/NanoHttpd/nanohttpd/releases/tag/nanohttpd-project-2.3.1
  • NanoHttpd的使用,使 “本地代理方式播放Android Sdcard中的m3u8視頻” Demo實作變得很簡單,這里不做具體介紹,有興趣的朋友可以自行下載了解,

下邊來主要來跟蹤學習NanoHttpd的原始碼...

三、NanoHttpd原始碼跟蹤學習

注:基于 NanoHttpd 2.3.1版本
NanoHttpd 2.3.1版本下載
https://github.com/NanoHttpd/nanohttpd/releases/tag/nanohttpd-project-2.3.1

NanoHTTPD大概的處理流程是:

  • 開啟一個服務端執行緒,系結對應的埠,呼叫 ServerSocket.accept()方法進入等待狀態
  • 每個客戶端連接均開啟一個執行緒,執行ClientHandler.run()方法
  • 客戶端執行緒中,創建一個HTTPSession會話,執行HTTPSession.execute()
  • HTTPSession.execute() 中會完成 uri, method, headers, parms, files 的決議,并呼叫如下方法:
// 自定義服務器時,亦需要多載該方法
// 該方法傳入引數中,已決議出客戶端請求的所有資料,多載該方法進行相應的業務處理
HTTPSession.serve(String uri, Method method, Map<String, String> headers, Map<String, String> parms, Map<String, String> files)
  • 組織Response資料,并呼叫ChunkedOutputStream.send(outputStream)回傳給客戶端

建議:
對于Http request、response 資料組織形式不是很了解的同學,建議自己了解后再閱讀NanoHTTPD原始碼,
也可參考我的另一篇文章:
HTTP 協議詳解
https://xiaxl.blog.csdn.net/article/details/104541274

3.1、NanoHTTPD.start

從服務器啟動開始學習...

/**
 * Start the server. 啟動服務器
 *
 * @param timeout timeout to use for socket connections. 超時時間
 * @param daemon  start the thread daemon or not. 守護執行緒
 * @throws IOException if the socket is in use.
 */
public void start(final int timeout, boolean daemon) throws IOException {
    // 創建一個ServerSocket
    this.myServerSocket = this.getServerSocketFactory().create();
    this.myServerSocket.setReuseAddress(true);

    // 創建 ServerRunnable
    ServerRunnable serverRunnable = createServerRunnable(timeout);
    // 啟動一個執行緒監聽客戶端請求
    this.myThread = new Thread(serverRunnable);
    this.myThread.setDaemon(daemon);
    this.myThread.setName("NanoHttpd Main Listener");
    this.myThread.start();
    //
    while (!serverRunnable.hasBinded && serverRunnable.bindException == null) {
        try {
            Thread.sleep(10L);
        } catch (Throwable e) {
            // on android this may not be allowed, that's why we
            // catch throwable the wait should be very short because we are
            // just waiting for the bind of the socket
        }
    }
    if (serverRunnable.bindException != null) {
        throw serverRunnable.bindException;
    }
}

從以上代碼中,可以看到:

  • 代碼前兩行,創建一個ServerSocket
  • 開啟一個執行緒,執行ServerRunnable,這里其實就是服務端啟動一個執行緒,用來監聽客戶端的請求,具體代碼在ServerRunnable中,

3.2、ServerRunnable.run()

@Override
public void run() {
    Log.e(TAG, "---run---");
    try {
        // bind
        myServerSocket.bind(hostname != null ? new InetSocketAddress(hostname, myPort) : new InetSocketAddress(myPort));
        hasBinded = true;
    } catch (IOException e) {
        this.bindException = e;
        return;
    }
    Log.e(TAG, "bind ok");
    do {
        try {
            Log.e(TAG, "before accept");
            // 等待客戶端連接
            final Socket finalAccept = NanoHTTPD.this.myServerSocket.accept();
            // 設定超時時間
            if (this.timeout > 0) {
                finalAccept.setSoTimeout(this.timeout);
            }
            // 服務端:輸入流
            final InputStream inputStream = finalAccept.getInputStream();
            Log.e(TAG, "asyncRunner.exec");
            // 執行客戶端 ClientHandler
            NanoHTTPD.this.asyncRunner.exec(createClientHandler(finalAccept, inputStream));
        } catch (IOException e) {
            NanoHTTPD.LOG.log(Level.FINE, "Communication with the client broken", e);
        }
    } while (!NanoHTTPD.this.myServerSocket.isClosed());
}

ServerRunnablerun()方法:

  • 呼叫 ServerSocket.bind 方法,系結對應的埠
  • 呼叫 ServerSocket.accept() 執行緒進入阻塞等待狀態
  • 客戶端連接后,會執行createClientHandler(finalAccept, inputStream)創建一個ClientHandler,并開啟一個執行緒,執行其對應的ClientHandler.run()方法
  • 自定義服務器時,多載Response HTTPSession.serve(uri, method, headers, parms, files)方法,對客戶端的請求資料做出處理

3.3、ClientHandler.run()

@Override
public void run() {
    Log.e(TAG, "---run---");
    // 服務端 輸出流
    OutputStream outputStream = null;
    try {
        // 服務端的輸出流
        outputStream = this.acceptSocket.getOutputStream();
        // 創建臨時檔案
        TempFileManager tempFileManager = NanoHTTPD.this.tempFileManagerFactory.create();
        // session 會話
        HTTPSession session = new HTTPSession(tempFileManager, this.inputStream, outputStream, this.acceptSocket.getInetAddress());
        // 執行會話
        while (!this.acceptSocket.isClosed()) {
            session.execute();
        }
    } catch (Exception e) {
        // When the socket is closed by the client,
        // we throw our own SocketException
        // to break the "keep alive" loop above. If
        // the exception was anything other
        // than the expected SocketException OR a
        // SocketTimeoutException, print the
        // stacktrace
        if (!(e instanceof SocketException && "NanoHttpd Shutdown".equals(e.getMessage())) && !(e instanceof SocketTimeoutException)) {
            NanoHTTPD.LOG.log(Level.SEVERE, "Communication with the client broken, or an bug in the handler code", e);
        }
    } finally {
        safeClose(outputStream);
        safeClose(this.inputStream);
        safeClose(this.acceptSocket);
        NanoHTTPD.this.asyncRunner.closed(this);
    }
}
  • TempFileManager臨時檔案是為了快取客戶端Post請求的請求Body資料(如果資料較小,記憶體快取;檔案較大,快取到檔案中)
  • 創建一個HTTPSession會話,并執行其對應的HTTPSession.execute()方法
  • HTTPSession.execute()中會對客戶端的請求進行決議

3.4、HTTPSession.execute()


@Override
public void execute() throws IOException {
    Log.e(TAG, "---execute---");
    Response r = null;
    try {
        // Read the first 8192 bytes.
        // The full header should fit in here.
        // Apache's default header limit is 8KB.
        // Do NOT assume that a single read will get the entire header
        // at once!
        // Apache默認header限制8k
        byte[] buf = new byte[HTTPSession.BUFSIZE];
        this.splitbyte = 0;
        this.rlen = 0;
        // 客戶端輸入流
        int read = -1;
        this.inputStream.mark(HTTPSession.BUFSIZE);
        // 讀取8k的資料
        try {
            read = this.inputStream.read(buf, 0, HTTPSession.BUFSIZE);
        } catch (SSLException e) {
            throw e;
        } catch (IOException e) {
            safeClose(this.inputStream);
            safeClose(this.outputStream);
            throw new SocketException("NanoHttpd Shutdown");
        }
        if (read == -1) {
            // socket was been closed
            safeClose(this.inputStream);
            safeClose(this.outputStream);
            throw new SocketException("NanoHttpd Shutdown");
        }
        // 分割header資料
        while (read > 0) {
            this.rlen += read;
            // header
            this.splitbyte = findHeaderEnd(buf, this.rlen);
            // 找到header
            if (this.splitbyte > 0) {
                break;
            }
            // 8k中剩余資料
            read = this.inputStream.read(buf, this.rlen, HTTPSession.BUFSIZE - this.rlen);
        }
        // header資料不足8k,跳過header資料
        if (this.splitbyte < this.rlen) {
            this.inputStream.reset();
            this.inputStream.skip(this.splitbyte);
        }
        //
        this.parms = new HashMap<String, List<String>>();
        // 清空header串列
        if (null == this.headers) {
            this.headers = new HashMap<String, String>();
        } else {
            this.headers.clear();
        }
        // 決議 客戶端請求
        // Create a BufferedReader for parsing the header.
        BufferedReader hin = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(buf, 0, this.rlen)));
        // Decode the header into parms and header java properties
        Map<String, String> pre = new HashMap<String, String>();
        decodeHeader(hin, pre, this.parms, this.headers);
        //
        if (null != this.remoteIp) {
            this.headers.put("remote-addr", this.remoteIp);
            this.headers.put("http-client-ip", this.remoteIp);
        }
        Log.e(TAG, "headers: " + headers);

        this.method = Method.lookup(pre.get("method"));
        if (this.method == null) {
            throw new ResponseException(Response.Status.BAD_REQUEST, "BAD REQUEST: Syntax error. HTTP verb " + pre.get("method") + " unhandled.");
        }
        Log.e(TAG, "method: " + method);

        this.uri = pre.get("uri");
        Log.e(TAG, "uri: " + uri);

        this.cookies = new CookieHandler(this.headers);
        Log.e(TAG, "cookies: " + this.cookies.cookies);

        String connection = this.headers.get("connection");
        Log.e(TAG, "connection: " + connection);
        boolean keepAlive = "HTTP/1.1".equals(protocolVersion) && (connection == null || !connection.matches("(?i).*close.*"));
        Log.e(TAG, "keepAlive: " + keepAlive);
        // Ok, now do the serve()

        // TODO: long body_size = getBodySize();
        // TODO: long pos_before_serve = this.inputStream.totalRead()
        // (requires implementation for totalRead())
        // 構造一個response
        r = serve(HTTPSession.this);
        // TODO: this.inputStream.skip(body_size -
        // (this.inputStream.totalRead() - pos_before_serve))

        if (r == null) {
            throw new ResponseException(Response.Status.INTERNAL_ERROR, "SERVER INTERNAL ERROR: Serve() returned a null response.");
        } else {
            String acceptEncoding = this.headers.get("accept-encoding");
            this.cookies.unloadQueue(r);
            // method
            r.setRequestMethod(this.method);
            r.setGzipEncoding(useGzipWhenAccepted(r) && acceptEncoding != null && acceptEncoding.contains("gzip"));
            r.setKeepAlive(keepAlive);

            // 發送response
            r.send(this.outputStream);
        }
        if (!keepAlive || r.isCloseConnection()) {
            throw new SocketException("NanoHttpd Shutdown");
        }
    } catch (SocketException e) {
        // throw it out to close socket object (finalAccept)
        throw e;
    } catch (SocketTimeoutException ste) {
        // treat socket timeouts the same way we treat socket exceptions
        // i.e. close the stream & finalAccept object by throwing the
        // exception up the call stack.
        throw ste;
    } catch (SSLException ssle) {
        Response resp = newFixedLengthResponse(Response.Status.INTERNAL_ERROR, NanoHTTPD.MIME_PLAINTEXT, "SSL PROTOCOL FAILURE: " + ssle.getMessage());
        resp.send(this.outputStream);
        safeClose(this.outputStream);
    } catch (IOException ioe) {
        Response resp = newFixedLengthResponse(Response.Status.INTERNAL_ERROR, NanoHTTPD.MIME_PLAINTEXT, "SERVER INTERNAL ERROR: IOException: " + ioe.getMessage());
        resp.send(this.outputStream);
        safeClose(this.outputStream);
    } catch (ResponseException re) {
        Response resp = newFixedLengthResponse(re.getStatus(), NanoHTTPD.MIME_PLAINTEXT, re.getMessage());
        resp.send(this.outputStream);
        safeClose(this.outputStream);
    } finally {
        safeClose(r);
        this.tempFileManager.clear();
    }
}
  • HTTPSession.execute() 完成了 uri, method, headers, parms, files 的決議
  • 完成決議后,呼叫Response serve(IHTTPSession session)方法,創建了一個Response
  • 完成Response資料組織后,這里會呼叫ChunkedOutputStream.send(outputStream)方法將資料發出去,

到這里,主要流程結束,其他細節需大家自己去用心研讀原始碼了,我的Demo中增加了很多中文注釋,可以幫助大家省下一部分力氣,就這樣了

相關參考

NanoHttpd GitHub
https://github.com/NanoHttpd/nanohttpd

NanoHttpd原始碼分析
https://www.iteye.com/blog/shensy-1880381

========== THE END ==========

wx_gzh.jpg

轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/28311.html

標籤:Android

上一篇:Android Q 深色主題舉例

下一篇:.obj 和 .mtl格式詳解

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • 【從零開始擼一個App】Dagger2

    Dagger2是一個IOC框架,一般用于Android平臺,第一次接觸的朋友,一定會被搞得暈頭轉向。它延續了Java平臺Spring框架代碼碎片化,注解滿天飛的傳統。嘗試將各處代碼片段串聯起來,理清思緒,真不是件容易的事。更不用說還有各版本細微的差別。 與Spring不同的是,Spring是通過反射 ......

    uj5u.com 2020-09-10 06:57:59 more
  • Flutter Weekly Issue 66

    新聞 Flutter 季度調研結果分享 教程 Flutter+FaaS一體化任務編排的思考與設計 詳解Dart中如何通過注解生成代碼 GitHub 用對了嗎?Flutter 團隊分享如何管理大型開源專案 插件 flutter-bubble-tab-indicator A Flutter librar ......

    uj5u.com 2020-09-10 06:58:52 more
  • Proguard 常用規則

    介紹 Proguard 入口,如何查看輸出,如何使用 keep 設定入口以及使用實體,如何配置壓縮,混淆,校驗等規則。

    ......

    uj5u.com 2020-09-10 06:59:00 more
  • Android 開發技術周報 Issue#292

    新聞 Android即將獲得類AirDrop功能:可向附近設備快速分享檔案 谷歌為安卓檔案管理應用引入可安全隱藏資料的Safe Folder功能 Android TV新主界面將顯示電影、電視節目和應用推薦內容 泄露的Android檔案暗示了傳說中的谷歌Pixel 5a與折疊屏新機 谷歌發布Andro ......

    uj5u.com 2020-09-10 07:00:37 more
  • AutoFitTextureView Error inflating class

    報錯: Binary XML file line #0: Binary XML file line #0: Error inflating class xxx.AutoFitTextureView 解決: <com.example.testy2.AutoFitTextureView android: ......

    uj5u.com 2020-09-10 07:00:41 more
  • 根據Uri,Cursor沒有獲取到對應的屬性

    Android: 背景:呼叫攝像頭,拍攝視頻,指定保存的地址,但是回傳的Cursor檔案,只有名稱和大小的屬性,沒有其他諸如時長,連ID屬性都沒有 使用 cursor.getInt(cursor.getColumnIndexOrThrow(MediaStore.Video.Media.DURATIO ......

    uj5u.com 2020-09-10 07:00:44 more
  • Android連載29-持久化技術

    一、持久化技術 我們平時所使用的APP產生的資料,在記憶體中都是瞬時的,會隨著斷電、關機等丟失資料,因此android系統采用了持久化技術,用于存盤這些“瞬時”資料 持久化技術包括:檔案存盤、SharedPreference存盤以及資料庫存盤,還有更復雜的SD卡記憶體儲。 二、檔案存盤 最基本存盤方式, ......

    uj5u.com 2020-09-10 07:00:47 more
  • Android Camera2Video整合到自己專案里

    背景: Android專案里呼叫攝像頭拍攝視頻,原本使用的 MediaStore.ACTION_VIDEO_CAPTURE, 后來因專案需要,改成了camera2 1.Camera2Video 官方demo有點問題,下載后,不能直接整合到專案 問題1.多次拍攝視頻崩潰 問題2.雙擊record按鈕, ......

    uj5u.com 2020-09-10 07:00:50 more
  • Android 開發技術周報 Issue#293

    新聞 谷歌為Android TV開發者提供多種新功能 Android 11將自動填表功能整合到鍵盤輸入建議中 谷歌宣布Android Auto即將支持更多的導航和數字停車應用 谷歌Pixel 5只有XL版本 搭載驍龍765G且將比Pixel 4更便宜 [圖]Wear OS將迎來重磅更新:應用啟動時間 ......

    uj5u.com 2020-09-10 07:01:38 more
  • 海豚星空掃碼投屏 Android 接收端 SDK 集成 六步驟

    掃碼投屏,開放網路,獨占設備,不需要額外下載軟體,微信掃碼,發現設備。支持標準DLNA協議,支持倍速播放。視頻,音頻,圖片投屏。好點意思。還支持自定義基于 DLNA 擴展的操作動作。好像要收費,沒體驗。 這里簡單記錄一下集成程序。 一 跟目錄的build.gradle添加私有mevan倉庫 mave ......

    uj5u.com 2020-09-10 07:01:43 more
最新发布
  • 歡迎頁輪播影片

    如圖,引導開始,球從上落下,同時淡入文字,然后文字開始輪播,最后一頁時停止,點擊進入首頁。 在來看看效果圖。 重力球先不講,主要歡迎輪播簡單實作 首先新建一個類 TextTranslationXGuideView,用于影片展示 文本是類似的,最后會有個圖片箭頭影片,布局很簡單,就是一個 TextVi ......

    uj5u.com 2023-04-20 08:40:31 more
  • 【FAQ】關于華為推送服務因營銷訊息頻次管控導致服務通訊類訊息

    一. 問題描述 使用華為推送服務下發IM訊息時,下發訊息請求成功且code碼為80000000,但是手機總是收不到訊息; 在華為推送自助分析(Beta)平臺查看發現,訊息發送觸發了頻控。 二. 問題原因及背景 2023年1月05日起,華為推送服務對咨詢營銷類訊息做了單個設備每日推送數量上限管理,具體 ......

    uj5u.com 2023-04-20 08:40:11 more
  • 歡迎頁輪播影片

    如圖,引導開始,球從上落下,同時淡入文字,然后文字開始輪播,最后一頁時停止,點擊進入首頁。 在來看看效果圖。 重力球先不講,主要歡迎輪播簡單實作 首先新建一個類 TextTranslationXGuideView,用于影片展示 文本是類似的,最后會有個圖片箭頭影片,布局很簡單,就是一個 TextVi ......

    uj5u.com 2023-04-20 08:39:36 more
  • 【FAQ】關于華為推送服務因營銷訊息頻次管控導致服務通訊類訊息

    一. 問題描述 使用華為推送服務下發IM訊息時,下發訊息請求成功且code碼為80000000,但是手機總是收不到訊息; 在華為推送自助分析(Beta)平臺查看發現,訊息發送觸發了頻控。 二. 問題原因及背景 2023年1月05日起,華為推送服務對咨詢營銷類訊息做了單個設備每日推送數量上限管理,具體 ......

    uj5u.com 2023-04-20 08:39:13 more
  • iOS從UI記憶體地址到讀取成員變數(oc/swift)

    開發除錯時,我們發現bug時常首先是從UI顯示發現例外,下一步才會去定位UI相關連的資料的。XCode有給我們提供一系列debug工具,但是很多人可能還沒有形成一套穩定的除錯流程,因此本文嘗試解決這個問題,順便提出一個暴論:UI顯示例外問題只需要兩個步驟就能完成定位作業的80%: 定位例外 UI 組 ......

    uj5u.com 2023-04-19 09:16:23 more
  • FIDE重磅更新!性能飛躍!體驗有禮!

    FIDE 開發者工具重構升級啦!實作500%性能提升,誠邀體驗! 一直以來不少開發者朋友在社區反饋,在使用 FIDE 工具的程序中,時常會遇到諸如加載不及時、代碼預覽/渲染性能不如意的情況,十分影響開發體驗。 作為技術團隊,我們深知一件趁手的開發工具對開發者的重要性,因此,在2023年開年,FinC ......

    uj5u.com 2023-04-19 09:16:15 more
  • 游戲內嵌社區服務開放,助力開發者提升玩家互動與留存

    華為 HMS Core 游戲內嵌社區服務提供快速訪問華為游戲中心論壇能力,支持玩家直接在游戲內瀏覽帖子和交流互動,助力開發者擴展內容生產和觸達的場景。 一、為什么要游戲內嵌社區? 二、游戲內嵌社區的典型使用場景 1、游戲內打開論壇 您可以在游戲內繪制論壇入口,為玩家提供沉浸式發帖、瀏覽、點贊、回帖、 ......

    uj5u.com 2023-04-19 09:15:46 more
  • iOS從UI記憶體地址到讀取成員變數(oc/swift)

    開發除錯時,我們發現bug時常首先是從UI顯示發現例外,下一步才會去定位UI相關連的資料的。XCode有給我們提供一系列debug工具,但是很多人可能還沒有形成一套穩定的除錯流程,因此本文嘗試解決這個問題,順便提出一個暴論:UI顯示例外問題只需要兩個步驟就能完成定位作業的80%: 定位例外 UI 組 ......

    uj5u.com 2023-04-19 09:14:53 more
  • FIDE重磅更新!性能飛躍!體驗有禮!

    FIDE 開發者工具重構升級啦!實作500%性能提升,誠邀體驗! 一直以來不少開發者朋友在社區反饋,在使用 FIDE 工具的程序中,時常會遇到諸如加載不及時、代碼預覽/渲染性能不如意的情況,十分影響開發體驗。 作為技術團隊,我們深知一件趁手的開發工具對開發者的重要性,因此,在2023年開年,FinC ......

    uj5u.com 2023-04-19 09:14:08 more
  • 游戲內嵌社區服務開放,助力開發者提升玩家互動與留存

    華為 HMS Core 游戲內嵌社區服務提供快速訪問華為游戲中心論壇能力,支持玩家直接在游戲內瀏覽帖子和交流互動,助力開發者擴展內容生產和觸達的場景。 一、為什么要游戲內嵌社區? 二、游戲內嵌社區的典型使用場景 1、游戲內打開論壇 您可以在游戲內繪制論壇入口,為玩家提供沉浸式發帖、瀏覽、點贊、回帖、 ......

    uj5u.com 2023-04-19 09:08:34 more