Introduction to the one sdk architecture and the onesdk Architecture

Source: Internet
Author: User
Tags define abstract

Introduction to the one sdk architecture and the onesdk Architecture
Brief Introduction to the architecture of the one sdk for huanxin instant messaging SDK has been around for a year since its official release of version June 2014 in 2.0, from basic single chat functions to group chat functions, to implementation of chat rooms, SDK functions, stability, and integration are all improved and stable step by step. Thanks to the feedback and help provided by developers, so that our SDK can be quickly improved and improved in many aspects.
With the rise of the Internet of Things, the current SDK architecture of huanxin is still slightly inadequate for the future Iot platform, so we have to consider how to improve our architecture at the beginning of this year, it makes it easy to adapt to various mainstream platforms and IoT platforms.
Currently, both Android, IOS, and SDK maintain their own logic, causing a lot of inconvenience to 2.0 development. The same function requires two pieces of code to be maintained, the same bug must be fixed twice on different platforms. Due to the implementation of different platforms, the Android and IOS architectures are designed incorrectly and APIs are inconsistent, in addition, there are many communication problems between engineers on different platforms due to different implementations. As a result, the development progress of different platforms is usually different.
To address the above problems, we plan to develop SDK3.0 at the beginning of this year. We call it the one sdk. The basic idea is that we implement the common IM kernel, code can be maximized and reused by different platforms, but the design and implementation are facing huge challenges. How to adapt to different platforms and how to maximize code reuse is a problem.
One sdk Architecture Design

The Design of one sdk is divided into three layers: platform layer-Platfrom layer, adaptation layer-Porting layer, and core layer-Common layer.
The platform layer implements different interfaces based on different platforms and opens APIs that comply with the platform layer to third-party developers.
The adaptation layer is mainly applicable to some interfaces required by the one sdk core layer, and serves as a bridge between the two.
The core layer mainly provides IM functions and business logic to ensure maximum code reuse.
Considering cross-platform code sharing, one sdk is mainly implemented in C ++, a cross-platform language. At the platform layer, we plan to support Android, IOS, mac OS, Windows, Windows phone, Linux, Embedded Linux, and a widely used IOT platform-iot OS.
We will provide developers with different platforms and use the same API specifications as the platform to enable developers on different platforms to integrate sdks without difficulty. For example, we will provide JAVA to Android, objective-C for IOS and MAC, and C ++ for Linux and IOT platforms. Adaptation Layer
The Adaptation Layer mainly refers to some interface classes required by each platform to implement the core layer, such as the thread model, Timer model, database model, and HTTP model.
These models are related to the platform. For example, some platforms provide sqllite access, some do not, and some thread models and timer models all have their own implementation methods, such as iot OS, therefore, after the above model is implemented, the core layer can work, but some problems may also occur, which will be addressed in the specific implementation, but the structure is clear.
In fact, Android, Linux, IOS, Mac OS, and Windows all support C ++ 11, that is, all support the thread model provided by C ++ 11, therefore, the implementation of the thread models of these operating systems should be the same, so the code can be shared, but the database Anroid NDK does not support sqlite access, therefore, Android has two policies: Integration of sqlite source code and callback to the JAVA layer. The former is that the Code logic is clear, but the disadvantage is that the amount of code is increased.
There is also the HTTP model. The default android, iOS, Mac OS, and windows all have their own APIs, therefore, the one sdk policy is that if there is a platform with native http api support, we will try our best to use the platform, but like linux, we need third-party library support such as libcurl.
Therefore, the adaptation layer is of great significance to ensure that one sdk code sharing is maximized. The core layer of the core layer is a module that specifically implements the functions related to the ring information. It also contains several parts, including core business logic API implementation, abstract protocol layer, and independent real-time audio and video modules.
Core Common
The business logic layer is responsible for providing basic IM functions.


  • Session management
  • Send and receive messages
  • Logon authentication
  • Connection Management
Audio/Video Call
The real-time audio/video module is an independent module that can exist independently. This module can be flexibly processed without being loaded when necessary.

  • Real-time audio and video
  • Multiplayer speech
Abstract Protocol Layer
The Protocol abstraction layer is mainly used to deal with specific IM underlying protocols. This layer is relatively independent and mainly implements the IM transmission protocol defined by huanxin. It also serves as a basis for future protocol transformation and expansion.

  • Define abstract message carrier
  • Basic message sending
  • Basic message callback
  • Define basic notifications
We plan to implement the above one sdk architecture. Now some basic designs have been implemented in the Linux SDK. Let's continue to understand the Linux SDK.
Linux SDK after a few months of development, we have launched a Linux SDK test, interested developers can try to download our official website http://www.easemob.com/downloads.
EMChatClient Facade developers can access any function of stopping IM
  • Login Registration
  • Message sending and receiving, supports TXT, IMAGE, VIDEO, AUDIO, FILE, LOCATION, type message
  • Session management
  • Contact Management
When developing the linux SDK, we used many excellent features provided by C ++ 11, such as lambda, shared ptr, thread, and other new features, this allows us to quickly and efficiently develop the Linux SDK test version.
Lambda makes our code logic clearer. shared ptr makes memory management easier. The use of thread enables us to quickly establish a thread model and accelerate development.
We have implemented the thread model, database model, Timer model and HTTP model in the Linux SDK porting layer.
  • Thread model, which is encapsulated using the thread of C ++ 11
  • Database model, using Linux sqlite
  • HTTP model, we use Libcurl for encapsulation
  • Timer model, we use C ++ 11 for encapsulation
We are still busy with the Linux SDK, and the development of group and real-time audio and video functions is still in progress, but we also encountered some problems during the development process, for example, the linux platform does not have the same database support, so it is bound to make some changes to our architecture, and some refactoring work is in progress, we hope to achieve most of the functions by the end of August.
Starting with the linux SDK, most embedded smart platforms are dominated by linux, so the first step to develop the Linux SDK is also necessary. Thanks to our engineers, my Linux SDK already supports Raspberry Pi's development environment, which is good news for many developers.
For details about how to integrate the Linux SDK, refer to the instructions on integrating IM Linux SDK.
Looking forward to the Linux SDK is only the first step to implement our one sdk. In the second half of the year, we will also implement the one sdk-based Android, IOS, mac OS, and mainstream Iot platform sdks, by referring to the implementation method of the Linux SDK, we believe that one sdk can be implemented.
We will further cooperate with major IOT platform suppliers to implement the ring letter SDK for a specific IOT platform, so that the ring letter instant messaging platform ecosystem will grow stronger.

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.