I wrote an article Cross-platform development with Chromium to describe how to develop an application cross-platform with chromium simply. After a period of efforts, we applied it into Kanbox successfully. Now we can shared the design by this article.

1, Architecture

As we saw, there are four layers in the architecture of Kanbox’s SDK:(From bottom to top)

  1. Chromium Framework: Foundation for “cross-platform”; Encapsulating basic modules such as base(json, serialization, encoding..), net(dns, proxy, http, https..), sql and so on.
  2. Kanbox Framework: Provides multi-threading, application initialization, global notification, and any other common needed by an application.
  3. Kanbox SDK: SDK layer of Kanbox implements binsiness relatived functions and exposes API of each module.
  4. API Layer: API layer of Kanbox supports the API in different platform(such as Objective-C in iOS, Java in Android).It encapsulates the Kanbox SDK’s API by different languages.

2, Thread Model

There will be serval threads while the Kanbox SDK is running:

  1. UI Thread: This is the UI control working thread, it will be created while application starts.
  2. API Thread: This is the SDK start up’s thread, which is called the RunKanbox method. It is also responsible for receiving all callback, as we saw above, each API callback will be called on this thread.
  3. SYNC Thread: There will be many tasks which need to work synchronized, here is the thread to execute tasks and do many calculations.
  4. IO Thread: It’s for networking such as DNS protocol resolving and HTTP protocol handling.
  5. FILE Blocking Thread Pool: There will be a thread pool for blocking operation such as file read/write.

The flowchart above shows how the application work with Kanbox SDK and how the Login API works. Btw, UI Response is called through Event BUS on API Thread, Kanbox SDK will be not callback on UI Thread automatically.

3, Physical Form

The graph shows the physical form of Kanbox’s SDK in iOS and Android. In iOS, it is a Fake Framework and supplying API written by Objective-C. In Android, there are jar and so files. The kanbox_sdk.jar exposes the API writtent by Java and called by the application layer.

评论需要翻墙 for disqus