TYPESDK Hand Tour Aggregation SDK client design ideas and architecture of the second: Android platform unified interface structure and ideas

Source: Internet
Author: User

In the previous "Basic principles of TYPESDK Aggregation SDK design," we mentioned that the design of the aggregation SDK needs to design the interface of the development platform, as well as the design of the release platform of the aggregation of these 2 large modules. Well, let's talk about it today. One of the publishing platforms: the unified interface structure and ideas of the Android platform.

I. Related needs

For the unified interface of the Android platform, we need to take into account the following specific points:

1. External need to have a unified interface, to ensure that different channel SDK for the same game, is to call the same interface, passing the same parameters

2. Internal need a set of well-expanded framework, can deal with different channels of SDK differences

Second, the design of the module

So for these considerations, the unified interface of the Android platform, we will be mainly divided into the following sections to design:

1. Infrastructure Design

2. Concrete Channel Realization Class

3. Unify the interface of external platform

4. Cross-platform Interaction design

Third, the specific details

1. A unified infrastructure

For the unified infrastructure, we have designed the following main framework

We basically implemented a structure like this.

1. We create a generic base abstract class (Baseactivity).

This class contains all the SDKs, but implements different interfaces, which act as abstract functions that require the implementation classes of each channel.

1.1 Initializing interface: void Init ()

1.2 Login interface: void login ()

1.3 Logout interface: void logout ()
1.4 Payment Interface: String Pay (String _json_string)

1.5 Submitting player data: void Updateplayerinfo (String _json_string)

1.6 Display User center: void Showplayercenter ()

1.7 Big Game (kill process): void exit games ();

1.8 Show share void Showshare (String _json_string)

A generic abstraction interface is also required as an extension of the SDK framework

1.9 Invoke the function in the concrete implementation class according to the function name:

String Doanyfunction (String _function_name,string _json_string)

We also include a generic fixed implementation interface that complements the SDK framework

1.10. Get the configuration of the local channel: String Getplatfrominfo ()

1.11. Get user information cached on the Android layer: string GetUserInfo ()

2. We create our own implementation class BONJOUR_XX for each channel individually, depending on the SDK of each channel.

2.1 This class inherits the generic framework base class (Baseactivity).

2.2 In this framework, implement all the abstract interfaces of the base class. If you do not have the functionality of the interface, you also need to do the appropriate processing, such as output log log.

2.3 At the same time, the class can increase the channel's own special interface (for example, get friends list)

3. The publishing platform has a unified class for external calling interface implementations: mainactivity

3.1.mainActivity is required to inherit unityplayeractivity when it is called to unity. When calling COCOS2DX, you need to inherit cocos2dxactivity. Our main purpose is to call the development platform of the game, that is, the game development platform is which, then we need to write such a call to its mainactivity.

3.2 mainactivity need to unify the external interface name, and in each interface, using the Bonjour_xx instance object, to implement the business logic of the specific interface

3.2 mainactivity needs to be able to allow the development platform (UNITY/COCOS2DX) to use BONJOUR_XX to invoke the generic extended functions of the base class

4. Cross-Platform Interaction section

Cross-platform interaction we need to consider two things

A. How to invoke the development platform function from the publishing platform

B. How to invoke the Publish platform function from the development platform

1. On the Android layer, all we need to do is to put the functions called for unity in the previously mentioned mainactivty, and in unity you can call mainactivity functions directly from the function name.

2. On the unity layer, we provide a common cross-platform calling interface

void Unitysendmessage (String beheaver_name, String function_name, string json_string);

We just need to know the name of the script that the unity part uses to receive the message, the name of the script function to execute, and the arguments passed, so we can call Unity's response function.

Android to the Unity platform to pass data and call functions, mainly through the message mechanism to send messages

Unity passes parameters and call functions to the Android platform, using the function name to invoke the interface in mainactivity with reflection.

These are the details of the aggregation SDK design ideas for our Android publishing platform, and we'll cover the details of the design ideas for the iOS Aggregation SDK in the next chapter.

The project is open source, and you are interested in writing your own aggregation SDK for your own research or reference project.
Project Address: Https://code.csdn.net/typesdk_code
Project Address: HTTPS://GITHUB.COM/TYPESDK

TYPESDK Hand Tour Aggregation SDK client design ideas and architecture of the second: Android platform unified interface structure and ideas

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.