01/10/2025 10:53:00
Extension Module
I. Overview
MSDK provides the Extension module to encapsulate functions that cannot reuse the existing MSDK interfaces, such as the built-in game mall of the channel.
There is currently no channel that supports the Extension module by now.
II. Guide on how to access the module
2.1 Preconditions
Recommend the Extension module's calling process:
- Initialize SDK
- Register the extension function callback
- Call the Extension module's function interfaces
2.2 Register the callback
1) Functional description
For MSDK Extension module's callback, the game needs to register the callback function for processing;
2) Interface declaration
public static event OnMSDKRetEventHandler<MSDKExtendRet> ExtendRetEvent;
class MSDKExtendObserver
{
public:
virtual void OnExtendNotify(const MSDKExtendRet &extendRet) {};
};
3) Demo code
MSDKExtend.ExtendRetEvent += OnExtendRetEvent;
public void OnExtendRetEvent(MSDKBaseRet baseRet)
{
// WeChat and testMethod need to be replaced with a specific channel name and method name
if (extendRet.Channel.Equals("WeChat") && extendRet.ExtendMethodName.Equals("testMethod")) {
//
}
SampleInstance.showRetDialog (extendRet.ExtendMethodName, extendRet);
}
// It is needed to remove the listener when destroying AccountEvent
private void OnDestroy()
{
MSDKExtend.ExtendRetEvent -= OnExtendRetEvent;
}
MSDKExtend::SetExtendObserver(new MyExtendObserver());
class MyExtendObserver : public MSDKExtendObserver {
public:
void OnExtendNotify(const MSDKExtendRet &extendRet) {
handleCallback(extendRet, extendRet.methodNameID);
};
};
2.3 Call of the channel's extension function
1) Functional description
The Extension module provides a unified extension function calling interface, and all functions of the Extension module will be uniformly implemented with this method. A game needs to pass in the channel name (channel
), the method name (extendMethodName
) and the method parameter list (paramsJson
, Json format) when using the functions of the Extension module. MSDK Core will look for the corresponding method according to the channel name and the method name and call the Extend plugin to process it. The specific content required needs to be filled in according to the requirements of different channels.
2) Interface declaration
public static string Invoke(string channel, string extendMethodName, string paramsJson)
static string Invoke(const string& channel, const string& extendMethodName, const string& paramsJson);
3) Description of input parameters
Parameter name | Parameter type | Description |
---|---|---|
channel | string | Channel information, such as "WeChat", "QQ", "Facebook" |
extendMethodName | string | Method name of the Extension module |
paramsJson | string | The method parameter list, JSON format |
4) Demo code
string result = MSDKExtend.Invoke("WeChat", "testMethod", "{\"param\":\"value\"}");
string result = MSDKExtend::Invoke("WeChat", "testMethod", "{\"param\":\"value\"}");
All rights reserved.