Switching from GCloud to Player Network SDK
Replace the SDK
Replace GCloud MSDK with Player Network SDK in your project directory.
- Unity
- Unreal Engine
Remove the GCloud MSDK plugin directory from the project.
- Remove SDK scripts. The script directory:
MSDKCore
,MSDKBugly
, andMSDKFirebase
folders under theAssets/GCloudSDK/Scripts/
directory. - Remove Android plugin directories:
Assets/Plugins/Android/gcloudsdk-msdk-xxx
directory and relative third-party plugin directories. - Remove Android resource files:
MSDKConfig.ini
,MSDKRetMsg.json
,MSDKBuglyConfig.json
,msdk_permission_content.html
, andmsdk_policy_content.html
under theAssets/Plugins/Android/assets/
directory. - Remove GCloud MSDK related code from
Android mainTemplate.gralde
. - Remove iOS plugin directory
Assets/Plugins/iOS/GCloudSDK/MSDKxxx
.
- Remove SDK scripts. The script directory:
Switch to Player Network backend service.
Remove the GCloud MSDK plugin directory from the project.
- Remove the
Plugins/MSDK
folder. - Remove MSDK related code in the project.
PrivateDependencyModuleNames.AddRange(new string[] {"MSDKPlugin"});
- Remove the
Switch to Player Network backend service.
Client Code Adaptation
The GCloud MSDK is successfully replaced with Player Network SDK, you need to adapt client code to Player Network SDK.
Adapting to Player Network SDK
- Unity
- Unreal Engine
Player Network SDK provides API encapsulation for the Unity engine:
- All interfaces are in the
INTLAPI.cs
file. - All data structure definitions are in the
INTLDefine.cs
file. - All error codes are in the
INTLErrorCode.cs
file.
Games only need to take note of the three scripts mentioned above, not the implementation of the internal logic.
- Player Network SDK optimizes the interface encapsulation. For example, the naming of the interface is more direct, rarely used fields such as
subChannel
are removed from the login interface, and so on. - Player Network SDK optimizes the callback of each module. It uses
INTLAPI.AddxxxObserver
andINTLAPI.RemovexxxObserver
methods to declare callbacks. All callbacks are defined in theINTLAPI.cs
file.
The following section takes the login interface as an example to show code adaptation.
Player Network SDK provides API encapsulation for Unreal Engine. The APIs can be called directly in Unreal C++. Player Network SDK also provides blueprint interfaces, and games can use the interface based on actual usage habits.
GCloud MSDK does not provide additional encapsulation for Unreal Engine. Games need to achieve data structure encapsulation for Unreal Engine on their own.
The following section takes the login interface as an example to show code adaptation.
Code Sample
- Unity
- Unreal Engine
To implement login through MSDK, add login observer as follows:
// Declare the callback
MSDKLogin.LoginRetEvent += OnLoginRetEvent;
// Process the callback function
private void OnLoginRetEvent(MSDKLoginRet loginRet)
{
Debug.Log ("OnLoginRetNotify in Login");
// ...
}
// Call the login interface
MSDKLogin.Login(MSDKChannel.WeChat);
To implement login through Player Network SDK, add login observer as follows:
// Declare the callback
INTLAPI.AddAuthResultObserver(OnAuthResultEvent);
// Process the callback function
public void OnAuthResultEvent(INTLAuthResult ret)
{
Debug.Log ("OnAuthResultEvent in Login");
//...
}
// Call the login interface
INTLAPI.Login(INTLChannel.Facebook);
C++ callback
If the MSDK C++ generic code interface is already encapsulated, directly use the Player Network SDK C++ interface.
To implement login through MSDK, add a login listener that inherits from IMSDKLoginLister
as follows:
class GameLoginListener : public IMSDKLoginListener
{
void OnLoginNotify(MSDKLoginRet &loginRet) {
UE_LOG(LogTemp, Warning, TEXT("OnLoginNotify called"));
}
void onGetAccountInfoNotify(MSDKAuthInfoRet &result) {
}
};
MSDKLogin::Login("Guest");
A simple adaptation can be done as follows:
// Declare the callback
TScriptInterface<IINTLPluginObserver> Observer;
Observer.SetObject(this);
Observer.SetInterface(Cast<IINTLPluginObserver>(this));
UINTLSDKAPI::AddObserver(Observer);
// Call the login interface
UINTLSDKAPI::Login(EINTLLoginChannel::kChannelSteam);
Blueprint call
- Unity
- Unreal Engine
If games use the blueprint approach, use the blueprint interface provided by Player Network SDK as follows:
- Set the observer using the blueprint.
- Call the login interface using the blueprint.
Replace the Backend Service
The client adaptation is done. Replace the GCloud backend service with the Player Network backend service.
Player Network SDK provides backend services in the same way as the GCloud MSDK. Games only need to change the URL.
Differences between Player Network SDK and GCloud
From the overall service perspective, Player Network SDK optimizes the design of modules and interfaces, and provides a unified service to facilitate fast business integration. The main differences are:
- Player Network SDK provides a consistent way to manage backend data for a set of services.
- Player Network SDK provides engine-specific adaptation and encapsulation that facilitate game integration.