supersdk

文档中心

文档中心

下载文档

Login module


This module provides various functions that the channel must integrate. The game must be connected to all interfaces to ensure that it is properly placed in the channel. This module is a mandatory module.

Preparation before integration

The game developer needs to read the public configuration and prepare relevant configuration.

login

Interface Description: Invoking this interface will open the login window of the channel.

Note 1: The game cannot rely on login failure callbacks to handle the game logic processing. (There are no callbacks of some channel’s login failures )

Note 2: Parse the json data of the login successful callback, and send the ticket to the game server for verification. If the game server is successfully verified, then the SuperSDK login is successful. For details, see the login server documentation

Note 3: When the code returned from login result is less than or equal to -10000, the login of the channel SDK fails. The rest can be regarded as SuperSDK login verification failure or the network anomaly.

Interface invoke:

SuperSDK.getInstance().Invoke(SuperSDKPlatform.MODULE_NAME, SuperSDKPlatform.FUNC_LOGIN, null);

interface callback:

public void OnCallBack(string moduleName, string funcName, string result)
{
    Debug.Log("moduleName:" + moduleName);
    Debug.Log("funcName:" + funcName);
    Debug.Log("result:" + result);

    JsonData resultData = JsonMapper.ToObject(result);
    //平台模块回调
    if (moduleName.Equals(SuperSDKPlatform.MODULE_NAME))
    {
        if (funcName.Equals(SuperSDKPlatform.FUNC_LOGIN))
        {
            //处理登录回调
            JsonData resultData = JsonMapper.ToObject(result);
            int code = (int)resultData["code"];
            string msg = JsonMapper.ToJson(resultData["data"]);
            if (code == SuperSDKConstants.SUCCESS)
            {
                //SDK登录成功

                //解析msg保存loginData和user_id
                JsonData mData = JsonMapper.ToObject(msg);

                //保存Ticket,需要发送游戏服务端进行验证
                string ticket = mData["osdk_ticket"].ToString();

                //ticket解密后,解析获取用户id
                string ticketJson = StringUtil.Base64ToCommonString(mData["osdk_ticket"].ToString());
                string userId = JsonMapper.ToObject(ticketJson)["osdk_user_id"].ToString();
            }
            else
            {
                //SDK登录失败
                //注意:游戏不能依赖此接口处理逻辑
            }
        }
    }
}

Log printing:

moduleName:platform
funcName:login
result:
{
    "code": 1,
    "data": {
        "data": {
            "uid": "227"
        },
        "msg": "登录成功",
        "osdk_ticket": "eyJvc2RrX2dhbWVfaWQiOiIxOTYzNzc1MzgiLCJ1c2VyX2lkIjoiMjI3IiwibG9naW5fc2RrX25hbWUiOiJEZW1vIiwiY2hhbm5lbF9pZCI6IjAiLCJleHRlbmQiOiJ7XCJleHRlbmRcIjpcIjIxNTB8OTR8MFwiLFwib3V0ZXJfZXh0ZW5kXCI6XCIyMTUwfDk0fDBcIn0iLCJhY2NvdW50X3N5c3RlbV9pZCI6IjAwNjEwMDAiLCJvc2RrX3VzZXJfaWQiOiIwMDYxMDAwXzIyNyIsImlwIjoiMTkyLjE2OC4xMjMuMTU3IiwiY291bnRyeSI6IjAwIiwidGltZSI6MTQ5ODY1NzE0Nywic2lnbiI6IjM1MGRlYzRkZWQxM2Q2NmM1NGY3MjczZmMwODU2Y2I4In0=",
        "status": 1,
        "userinfo": {
            "login_sdk_name": "Demo",
            "user_id": "227"
        }
    },
    "msg": "login success"
}

Logout (required)

Interface description: After successful login, log out the currently account and invoke the interface.

Note: This interface is used for switching game accounts. The portal is generally placed in the following scenarios:

1. Login scenario,display of the account is successfully logged in.

2, the main game scene, display of setting interface.

Interface invoke:

//接口描述:判断第三方渠道是否有注销接口
//注意:如果游戏有特殊需求,可以判断该接口,再决定是否调用注销接口(非必接)
bool hasLogout = SuperSDK.getInstance().InvokeBool(SuperSDKPlatform.MODULE_NAME, SuperSDKPlatform.FUNC_HAS_LOGOUT, null);
//注销接口,一般情况下,游戏可以直接调用该接口
SuperSDK.getInstance().Invoke(SuperSDKPlatform.MODULE_NAME, SuperSDKPlatform.FUNC_LOGOUT, null);

Interface callback:

public void OnCallBack(string moduleName, string funcName, string result)
{
    Debug.Log("moduleName:" + moduleName);
    Debug.Log("funcName:" + funcName);
    Debug.Log("result:" + result);

    JsonData resultData = JsonMapper.ToObject(result);
    //平台模块回调
    if (moduleName.Equals(SuperSDKPlatform.MODULE_NAME))
    {
        if (funcName.Equals(SuperSDKPlatform.FUNC_LOGOUT))
        {
            //处理注销结果
            JsonData resultData = JsonMapper.ToObject(result);
            if ((int)resultData["code"] == SuperSDKConstants.SUCCESS)
            {
                //注销成功
                //切回到登录场景,重置角色信息
            }
        }
    }
}

Log printing:

moduleName:platform
funcName:logout
result:{"code":1,"msg":"logout success"}

login page (required)

Interface Description: Invoking when the game opens the login page. This interface is invoked when you open the login page for the first time, and it also need to be invoked when log back to the login page.

Interface invoke:

SuperSDK.getInstance().Invoke(SuperSDKPlatform.MODULE_NAME, SuperSDKPlatform.FUNC_OPEN_LOGIN_PAGE, null);

enterGame (required)

Interface description: When enters the game main scene from the login scene or the create role scene, the interface needs to be invoked to report data.

Note: You need to ensure that the “enterGame” is invoked before the “createRole”. There might be two scenarios:

* Enter the game first, then create a role. The first time you enter the game, there is no data, don’t report it. After the first time, if there is data while entering the game, report it. The game needs to invoke the enterGame interface first, then invoke the createRole interface.

* Create a role first, then enter the game. When creating a role, the game needs to invoke enterGame interface first, and then invoke createRole interface. Do not repeatedly invoke enterGame interface when entering the game. When the user has a role, the enterGame interface can be invoked upon entering the game.

Interface invoke:

Dictionary<string, object> roleDic = new Dictionary<string, object>();
roleDic.Add(SuperSDKPlatform.KEY_ROLE_ID, "roleId");//游戏创建的角色ID
roleDic.Add(SuperSDKPlatform.KEY_ROLE_NAME, "roleName");//角色名称
roleDic.Add(SuperSDKPlatform.KEY_ROLE_LEVEL, "roleLevel");//角色等级
roleDic.Add(SuperSDKPlatform.KEY_VIP_GRADE, "vip");//角色vip
roleDic.Add(SuperSDKPlatform.KEY_SERVER_ID, "serverId");//服务器ID
roleDic.Add(SuperSDKPlatform.KEY_SERVER_NAME, "serverName");//服务器名称
roleDic.Add(SuperSDKPlatform.KEY_OP_SID, "opSid");//渠道服务器ID
roleDic.Add(SuperSDKPlatform.KEY_ROLE_CREATE_TIME, "roleCreateTime");//必传,创角时间,必须为服务器时间,必须为10位数字,如1498043738
//奇虎360渠道要求参数
roleDic.Add("professionid", "6");    // 必传,职业ID,必须为数字,如果有则必传,如果没有,请说明原因
roleDic.Add("profession", "武士");   // 必传,职业名称,如果有则必传,如果没有,请说明原因
roleDic.Add("gender", "男");         // 必传,性别,只能传"男"、"女",如果有则必传,如果没有,请说明原因
roleDic.Add("power", "132323000");   // 必传,战力数值,必须为数字,如果有则必传,如果没有,请说明原因
roleDic.Add("balance", "0");         // 必传,帐号余额,必须为数字,如果有则必传,如果没有,请说明原因
roleDic.Add("partyid", "120");       // 必传,所属帮派帮派ID,必须为数字,如果有则必传,如果没有,请说明原因
roleDic.Add("partyname", "一笑倾城"); // 必传,所属帮派名称,如果有则必传,如果没有,请说明原因
roleDic.Add("partyroleid", "1");     // 必传,帮派称号ID,必须为数字,帮主/会长必传1,其他可自定义,如果有则必传,如果没有,请说明原因
roleDic.Add("partyrolename", "帮主");// 必传,帮派称号名称,如果有则必传,如果没有,请说明原因
roleDic.Add("friendlist", "[{\"roleid\":1,\"intimacy\":\"0\",\"nexusid\":\"600\",\"nexusname\":\"情侣\"},{\"roleid\":2,\"intimacy\":\"1\",\"nexusid\":\"200\",\"nexusname\":\"仇人\"}]");      
                                     // 必传,好友关系,如果有则必传,如果没有,请说明原因
//A站渠道要求参数
roleDic.Add("isNewPlayer", "true");  // 必传,是否为全区服第一次创角,只能传"true"、"false"。

//调用进入游戏接口
SuperSDK.getInstance().Invoke(SuperSDKPlatform.MODULE_NAME,SuperSDKPlatform.FUNC_ENTER_GAME,roleDic);

createRole (required)

Description of the interface: After successfully create a role, you need to call this interface to report data.

Note: You need to ensure that the “enterGame” is invoked before the “createRole”. There might be two scenarios:

* Enter the game first, then create a role. The first time you enter the game, there is no data, don’t report it. After the first time, if there is data while entering the game, report it. The game needs to invoke the enterGame interface first, then invoke the createRole interface.

* Create a role first, then enter the game. When creating a role, the game needs to invoke enterGame interface first, and then invoke createRole interface. Do not repeatedly invoke enterGame interface when entering the game. When the user has a role, the enterGame interface can be invoked upon entering the game.

Interface invoke:

Dictionary<string, object> roleDic = new Dictionary<string, object>();
roleDic.Add(SuperSDKPlatform.KEY_ROLE_ID, "roleId");//游戏创建的角色ID
roleDic.Add(SuperSDKPlatform.KEY_ROLE_NAME, "roleName");//角色名称
roleDic.Add(SuperSDKPlatform.KEY_ROLE_LEVEL, "roleLevel");//角色等级
roleDic.Add(SuperSDKPlatform.KEY_VIP_GRADE, "vip");//角色vip
roleDic.Add(SuperSDKPlatform.KEY_SERVER_ID, "serverId");//服务器ID
roleDic.Add(SuperSDKPlatform.KEY_SERVER_NAME, "serverName");//服务器名称
roleDic.Add(SuperSDKPlatform.KEY_OP_SID, "opSid");//渠道服务器ID
roleDic.Add(SuperSDKPlatform.KEY_ROLE_CREATE_TIME, "roleCreateTime");//必传,创角时间,必须为服务器时间,必须为10位数字,如1498043738
//奇虎360渠道要求参数
roleDic.Add("professionid", "6");    // 必传,职业ID,必须为数字,如果有则必传,如果没有,请说明原因
roleDic.Add("profession", "武士");   // 必传,职业名称,如果有则必传,如果没有,请说明原因
roleDic.Add("gender", "男");         // 必传,性别,只能传"男"、"女",如果有则必传,如果没有,请说明原因
roleDic.Add("power", "132323000");   // 必传,战力数值,必须为数字,如果有则必传,如果没有,请说明原因
roleDic.Add("balance", "0");         // 必传,帐号余额,必须为数字,如果有则必传,如果没有,请说明原因
roleDic.Add("partyid", "120");       // 必传,所属帮派帮派ID,必须为数字,如果有则必传,如果没有,请说明原因
roleDic.Add("partyname", "一笑倾城"); // 必传,所属帮派名称,如果有则必传,如果没有,请说明原因
roleDic.Add("partyroleid", "1");     // 必传,帮派称号ID,必须为数字,帮主/会长必传1,其他可自定义,如果有则必传,如果没有,请说明原因
roleDic.Add("partyrolename", "帮主");// 必传,帮派称号名称,如果有则必传,如果没有,请说明原因
roleDic.Add("friendlist", "[{\"roleid\":1,\"intimacy\":\"0\",\"nexusid\":\"600\",\"nexusname\":\"情侣\"},{\"roleid\":2,\"intimacy\":\"1\",\"nexusid\":\"200\",\"nexusname\":\"仇人\"}]");      
                                     // 必传,好友关系,如果有则必传,如果没有,请说明原因
//A站渠道要求参数
roleDic.Add("isNewPlayer", "true");  // 必传,是否为全区服第一次创角,只能传"true"、"false"。

//调用创建角色接口
SuperSDK.getInstance().Invoke(SuperSDKPlatform.MODULE_NAME,SuperSDKPlatform.FUNC_CREATE_ROLE,roleDic);

levelUp(required)

Interface description: When the role is upgraded, you need to invoke this interface to report data.

Interface invoke:

Dictionary<string, object> roleDic = new Dictionary<string, object>();
roleDic.Add(SuperSDKPlatform.KEY_ROLE_ID, "roleId");//游戏创建的角色ID
roleDic.Add(SuperSDKPlatform.KEY_ROLE_NAME, "roleName");//角色名称
roleDic.Add(SuperSDKPlatform.KEY_ROLE_LEVEL, "roleLevel");//角色等级
roleDic.Add(SuperSDKPlatform.KEY_VIP_GRADE, "vip");//角色vip
roleDic.Add(SuperSDKPlatform.KEY_SERVER_ID, "serverId");//服务器ID
roleDic.Add(SuperSDKPlatform.KEY_SERVER_NAME, "serverName");//服务器名称
roleDic.Add(SuperSDKPlatform.KEY_OP_SID, "opSid");//渠道服务器ID
roleDic.Add(SuperSDKPlatform.KEY_ROLE_CREATE_TIME, "roleCreateTime");//必传,创角时间,必须为服务器时间,必须为10位数字,如1498043738
//奇虎360渠道要求参数
roleDic.Add("professionid", "6");    // 必传,职业ID,必须为数字,如果有则必传,如果没有,请说明原因
roleDic.Add("profession", "武士");   // 必传,职业名称,如果有则必传,如果没有,请说明原因
roleDic.Add("gender", "男");         // 必传,性别,只能传"男"、"女",如果有则必传,如果没有,请说明原因
roleDic.Add("power", "132323000");   // 必传,战力数值,必须为数字,如果有则必传,如果没有,请说明原因
roleDic.Add("balance", "0");         // 必传,帐号余额,必须为数字,如果有则必传,如果没有,请说明原因
roleDic.Add("partyid", "120");       // 必传,所属帮派帮派ID,必须为数字,如果有则必传,如果没有,请说明原因
roleDic.Add("partyname", "一笑倾城"); // 必传,所属帮派名称,如果有则必传,如果没有,请说明原因
roleDic.Add("partyroleid", "1");     // 必传,帮派称号ID,必须为数字,帮主/会长必传1,其他可自定义,如果有则必传,如果没有,请说明原因
roleDic.Add("partyrolename", "帮主");// 必传,帮派称号名称,如果有则必传,如果没有,请说明原因
roleDic.Add("friendlist", "[{\"roleid\":1,\"intimacy\":\"0\",\"nexusid\":\"600\",\"nexusname\":\"情侣\"},{\"roleid\":2,\"intimacy\":\"1\",\"nexusid\":\"200\",\"nexusname\":\"仇人\"}]");      
                                     // 必传,好友关系,如果有则必传,如果没有,请说明原因
//A站渠道要求参数
roleDic.Add("isNewPlayer", "true");  // 必传,是否为全区服第一次创角,只能传"true"、"false"。

//调用角色升级接口
SuperSDK.getInstance().Invoke(SuperSDKPlatform.MODULE_NAME,SuperSDKPlatform.FUNC_LEVEL_UP,roleDic);

Reach the game home page (required)

Interface Description: When the player enters the main game scene, invoke this interface to report data.

Note 1: If it’s a new user enters for the first time, be sure to invoke it after the “createRole” interface.

Interface invoke:

SuperSDK.getInstance().Invoke(SuperSDKPlatform.MODULE_NAME, SuperSDKPlatform.FUNC_OPEN_HOME_PAGE, null);

Forum, User center, Customer Service (required)

Interface description: channel expansion interface, invoke forum, user center, customer service and other interfaces will open the corresponding function interface of the channel.

Note 1: You need to judge whether the channel has a Forum, User Center, Customer Service interface. If required, you need to provide the corresponding UI in the game settings interface, if not, hide it.

Interface invoke:

//是否有论坛
bool hasForum = SuperSDK.getInstance().InvokeBool(SuperSDKPlatform.MODULE_NAME, SuperSDKPlatform.FUNC_HAS_FORUM, null);
if(hasForum) {
    //如果有论坛,打开论坛
    SuperSDK.getInstance().Invoke(SuperSDKPlatform.MODULE_NAME, SuperSDKPlatform.FUNC_OPEN_FORUM, null);
}
//是否有用户中心
bool hasUserCenter = SuperSDK.getInstance().InvokeBool(SuperSDKPlatform.MODULE_NAME,SuperSDKPlatform.FUNC_HAS_USER_CENTER,null);
if(hasUserCenter) {
    //如果有用户中心,打开用户中心
    SuperSDK.getInstance().Invoke(SuperSDKPlatform.MODULE_NAME, SuperSDKPlatform.FUNC_OPEN_USER_CENTER, null);
}
//是否有客服
bool hasCustomServer = SuperSDK.getInstance().InvokeBool(SuperSDKPlatform.MODULE_NAME, SuperSDKPlatform.FUNC_HAS_CUSOMER_SERVICE, null);
if(hasCustomServer) {
    //如果有客服,打开客服
    SuperSDK.getInstance().Invoke(SuperSDKPlatform.MODULE_NAME, SuperSDKPlatform.FUNC_OPEN_CUSOMER_SERVICE, null);
}

Exit (Andriod)(required)

Interface Description: Invoking this interface will open the channel exit confirmation window.

Note 1: Overseas games need to implement the exit confirmation pop-up windows.

Note 2: If this interface is not integrated, it will affect the destruction of the channel SDK resources, causing some channel games to fail to start next time.

Note 3: Please try to use the Unity orginal method Input.GetKeyDown (KeyCode.Escape) to determine the invoke. If it is invoked by the android orginal method, please listen to the down method, do not listen for up and other methods.

Interface invoke:

SuperSDK.getInstance().Invoke(SuperSDKPlatform.MODULE_NAME, SuperSDKPlatform.FUNC_EXIT, null);

Interface callback:

public void OnCallBack(string moduleName, string funcName, string result)
{
    Debug.Log("moduleName:" + moduleName);
    Debug.Log("funcName:" + funcName);
    Debug.Log("result:" + result);

    JsonData resultData = JsonMapper.ToObject(result);
    //平台模块回调
    if (moduleName.Equals(SuperSDKPlatform.MODULE_NAME))
    {
        if (funcName.Equals(SuperSDKPlatform.FUNC_EXIT))
        {
            //处理退出结果
            JsonData resultData = JsonMapper.ToObject(result);
            int code = json.getIntValue("code");
            if ((int)resultData["code"] == SuperSDKConstants.HAS_EXIT_PAGE_AND_PRESS_EXIT)
            {
                //退出游戏
                Application.Quit();
            }
        }
    }
}

Callback log printing:

moduleName:platform
funcName:exit
result:{"code":1,"msg":"exit success"}

辅助常量一览

常量字符串 实际字符串 描述
SuperSDKPlatform.MODULE_NAME platform 平台模块
登录
SuperSDKPlatform.FUNC_LOGIN login 登录方法
注销
SuperSDKPlatform.FUNC_HAS_LOGOUT hasLogout 渠道是否有注销接口
SuperSDKPlatform.FUNC_LOGOUT logout 注销方法
角色数据上报
SuperSDKPlatform.FUNC_ENTER_GAME enterGame 进入游戏方法
SuperSDKPlatform.FUNC_CREATE_ROLE createRole 创建角色方法
SuperSDKPlatform.FUNC_LEVEL_UP levelUp 角色升级方法
SuperSDKPlatform.KEY_ROLE_ID role_id 角色ID
SuperSDKPlatform.KEY_ROLE_NAME role_name 角色名称
SuperSDKPlatform.KEY_ROLE_LEVEL level 角色等级
SuperSDKPlatform.KEY_VIP_GRADE vip_grade 角色vip
SuperSDKPlatform.KEY_SERVER_ID server_id 服务器ID
SuperSDKPlatform.KEY_SERVER_NAME server_name 服务器名称
SuperSDKPlatform.KEY_OP_SID opSid 渠道服务器ID
SuperSDKPlatform.KEY_ROLE_CREATE_TIME roleCreateTime 创建角色时间,必须使用服务器时间,单位/s
论坛、用户中心、客服
SuperSDKPlatform.FUNC_HAS_FORUM hasForum 渠道是否有论坛功能方法
SuperSDKPlatform.FUNC_OPEN_FORUM openForum 打开渠道论坛方法
SuperSDKPlatform.FUNC_HAS_USER_CENTER hasUserCenter 渠道是否有个人中心方法
SuperSDKPlatform.FUNC_OPEN_USER_CENTER openUserCenter 打开渠道个人中心方法
SuperSDKPlatform.FUNC_HAS_CUSOMER_SERVICE hasCustomerService 渠道是否有客服方法
SuperSDKPlatform.FUNC_OPEN_CUSOMER_SERVICE openCustomerService 打开渠道客服方法
关闭游戏
SuperSDKPlatform.FUNC_EXIT exit 关闭游戏
打开登录页面、打开游戏主城页面
SuperSDKPlatform.FUNC_OPEN_LOGIN_PAGE openLoginPage 打开登录页面
SuperSDKPlatform.FUNC_OPEN_HOME_PAGE openHomePage 打开游戏首页
添加SuperSDK埋点
SuperSDKPlatform.FUNC_REPORT report 添加埋点方法名
SuperSDKPlatform.KEY_EVENT_ID event_id 事件ID