Options
All
  • Public
  • Public/Protected
  • All
Menu

Class YidunService

en

Provide the service of Yidun, don't instantiate this class directly, use netease.yidun.yidunService instead.

zh

提供易盾服务的类,请不要实例化该类,直接使用netease.yidun.yidunService即可

Hierarchy

  • YidunService

Index

Methods

clearInfoReceivers

  • clearInfoReceivers(): void
  • en

    Unregister all the callbacks registered by registInfoReceiver.

    zh

    取消registInfoReceiver注册过的所有回调

    example
    netease.yidun.yidunService.clearInfoReceivers();
    

    Returns void

devastatedMovement

  • devastatedMovement(): void
  • en

    Account logout, only supported on iOS, will be ignored if called on non-iOS.

    zh

    账号退出登录,仅支持iOS,在非iOS系统下调用会被忽略

    en

    NOTE: In order to switch account, you can call setRoleInfo for different account directly, the original account will automatically logout, you don't need to call this interface.

    zh

    注:您可以直接调用setRoleInfo来切换账号,会自动退出之前的账号,不需要调用该接口

    example
    netease.yidun.yidunService.devastatedMovement();
    

    Returns void

getDataSign

  • getDataSign(inputData: string, algIndex: number): string
  • en

    Get the verification result of the data, you need to send the result to game server for verification.

    zh

    获取指定数据的校验结果,您需要发送校验结果到游戏服务端,由游戏服务端进行校验

    Parameters

    • inputData: string

      En: The data for verification. Zh: 待校验数据

    • algIndex: number

      En: The algorithm index, please contact Yidun if you need it. Zh: 算法标识,需要请联系易盾人员

    Returns string

getToken

  • getToken(): Promise<string>
  • en

    Get an unique token from the anti-cheat module, the client need to send this token to the backend, then the backend use the token to request 'check' interface to get the detection result. For the detail about backend, please contact Yidun.

    zh

    向反作弊模块获取唯一凭证token,业务方客户端需要将此token提交到业务后端,业务后端再使用此token来请求check接口获取检测结果,后端相关接入请联系易盾

    example
    const token = await netease.yidun.yidunService.getToken();
    

    Returns Promise<string>

init

  • init(serverType?: ServerType, url?: string): void
  • en

    Initialize the anti-cheat, enable the anti-cheat service, need to be called after the game starts.

    zh

    初始化反外挂,开启反外挂服务,需要在游戏启动后调用

    example
    netease.yidun.yidunService.init();
    netease.yidun.yidunService.init(netease.yidun.ServerType.Other);
    netease.yidun.yidunService.init(netease.yidun.ServerType.ChineseMainland, 'https://www.netease163.com');
    

    Parameters

    • Optional serverType: ServerType

      En: Server area type, defaulted to Chinese Mainland, please see the documentation of ServerType for detail. Zh: 服务器地区类型,默认为中国大陆,详细请查看ServerType的文档

    • Optional url: string

      En: Transparent transmission server url, only supported on iOS, will be ignored on non-iOS, e.g. "https://www.netease163.com". Zh: 透传服务器地址,仅支持iOS,在非iOS系统下会被忽略,例如:"https://www.netease163.com"

    Returns void

ioctlAndroid

  • en

    General query, query information for root, simulator, anti-cheat and other functionalities. Only supported on Android, for iOS, please use ioctlIos instead, calling this interface on non-Android will return string 'Only supported on Android'.

    zh

    通用查询,查询root、模拟器、反外挂等信息以及其他定制功能。仅支持Android,iOS请使用ioctlIos,在非Android系统下调用该接口会返回字符串'Only supported on Android'

    example
    netease.yidun.yidunService.ioctlAndroid(netease.yidun.RequestCmdIdAndroid.GetEmulatorName, '');
    

    Parameters

    • request: RequestCmdIdAndroid

      En: Request type, please see the documentation of RequestCmdIdAndroid for detail. Zh: 请求类型,详细请查看RequestCmdIdAndroid的文档

    • data: string

    Returns string

ioctlIos

  • en

    General query, query information for jailbreak, sign, sdk version and other functionalities. Only supported on iOS, for Android, please use ioctlAndroid instead, calling this interface on non-iOS will return string 'Only supported on iOS'.

    zh

    通用查询,查询越狱、签名、SDK版本号等信息以及其他定制功能。仅支持iOS,Android请使用ioctlAndroid,在非iOS系统下调用该接口会返回字符串'Only supported on iOS'

    example
    netease.yidun.yidunService.ioctlIos(netease.yidun.RequestCmdIdIos.QueryRootStatus, '');
    

    Parameters

    • request: RequestCmdIdIos

      En: Request type, please see the documentation of RequestCmdIdIos for detail. Zh: 请求类型,详细请查看RequestCmdIdIos的文档

    • data: string

      En: Additional data for the request, please see the documentation of RequestCmdIdIos for detail. Zh: 请求的附加数据,详细请查看RequestCmdIdIos的文档

    Returns string

localSaveBytesDecode

  • localSaveBytesDecode(inputData: string, algIndex: number): Uint8Array
  • en

    Decode the data encoded by localSaveBytesEncode. Only supported on Android, calling this interface on non-Android will return an empty Uint8Array.

    zh

    解密localSaveBytesEncode加密过的数据。仅支持Android系统,在非Android系统下调用该接口会返回空的Uint8Array

    example
    const inputBytes = new Uint8Array([0, 255, 128, 4]);
    const encodedData = netease.yidun.yidunService.localSaveBytesEncode(inputBytes, 0);
    const decodedBytes = netease.yidun.yidunService.localSaveBytesDecode(encodedData, 0);
    

    Parameters

    • inputData: string

      En: The data for decoding. Zh: 需要解密的数据

    • algIndex: number

      En: If it is 0, bind with App installation. If it is 1, bind with App signature. Zh: 如果为0,和App安装绑定,如果为1,和App签名绑定

    Returns Uint8Array

localSaveBytesEncode

  • localSaveBytesEncode(inputData: Uint8Array, algIndex: number): string
  • en

    Provide encoding functionality for the data (in byte array form) that need to save locally. Only supported on Android, calling this interface on non-Android will return string 'Only supported on Android'.

    zh

    为需要本地存储的数据(为字节数组形式)提供加密功能。仅支持Android系统,在非Android系统下调用该接口会返回字符串'Only supported on Android'

    example
    const inputBytes = new Uint8Array([0, 255, 128, 4]);
    const encodedData = netease.yidun.yidunService.localSaveBytesEncode(inputBytes, 0);
    

    Parameters

    • inputData: Uint8Array

      En: The data for encoding. Zh: 需要加密的数据

    • algIndex: number

      En: If it is 0, bind with App installation. If it is 1, bind with App signature. Zh: 如果为0,和App安装绑定,如果为1,和App签名绑定

    Returns string

localSaveDecode

  • localSaveDecode(inputData: string, algIndex: number): string
  • en

    Decode the data encoded by localSaveEncode. Only supported on Android, calling this interface on non-Android will return string 'Only supported on Android'.

    zh

    解密localSaveEncode加密过的数据。仅支持Android系统,在非Android系统下调用该接口会返回字符串'Only supported on Android'

    example
    const inputData = 'Test text';
    const encodedData = netease.yidun.yidunService.localSaveEncode(inputData, 0);
    const decodedData = netease.yidun.yidunService.localSaveDecode(encodedData, 0);
    

    Parameters

    • inputData: string

      En: The data for decoding. Zh: 需要解密的数据

    • algIndex: number

      En: If it is 0, bind with App installation. If it is 1, bind with App signature. Zh: 如果为0,和App安装绑定,如果为1,和App签名绑定

    Returns string

localSaveEncode

  • localSaveEncode(inputData: string, algIndex: number): string
  • en

    Provide encoding functionality for the data (in string form) that need to save locally. Only supported on Android, calling this interface on non-Android will return string 'Only supported on Android'.

    zh

    为需要本地存储的数据(为字符串形式)提供加密功能。仅支持Android系统,在非Android系统下调用该接口会返回字符串'Only supported on Android'

    example
    const inputData = 'Test text';
    const encodedData = netease.yidun.yidunService.localSaveEncode(inputData, 0);
    

    Parameters

    • inputData: string

      En: The data for encoding. Zh: 需要加密的数据

    • algIndex: number

      En: If it is 0, bind with App installation. If it is 1, bind with App signature. Zh: 如果为0,和App安装绑定,如果为1,和App签名绑定

    Returns string

memorizerAlarmSpeedometer

  • en

    Get token to obtain cheating monitoring result in real time, only supported on iOS, will resolve an error result (code: 500) if called on non-iOS, please see the documentation of MemorizerAlarmSpeedometerResult for detail about return value.

    zh

    获取token,用于实时获取作弊监控结果,仅支持iOS,在非iOS系统下调用会返回一个错误结果(code: 500),关于返回值的详细请查看MemorizerAlarmSpeedometerResult的文档

    example
    const result = await netease.yidun.yidunService.memorizerAlarmSpeedometer();
    cc.log(result.code);
    if (result.code === 200) cc.log(result.token);
    

    Parameters

    • Optional timeout: number

      En: The timeout to get the token (in milliseconds), defaulted to 3000. Zh: 获取token的超时时间(单位:毫秒),默认为3000

    Returns Promise<MemorizerAlarmSpeedometerResult>

readyForOpportunity

  • en

    Set transparent transmission type, only supported on iOS, will be ignored if called on non-iOS. if you don't use transparent transmission, you don't need to call this interface. NOTE: in order to use transparent transmission, you need to pass url of your transparent transmission server when calling the init.

    zh

    设置透传的类型,仅支持iOS,非iOS系统下调用会被忽略。不使用透传,您不需要调用该接口。注:使用透传需要在调用init时通过url参数传递透传服务器地址

    example
    netease.yidun.yidunService.readyForOpportunity(netease.yidun.TransparentTransmissionType.ForceTransparentTransmission);
    

    Parameters

    • type: TransparentTransmissionType

      En: The transparent transmission type you want, please see the documentation of TransparentTransmissionType for detail. Zh: 您想要的透传类型,详细请查看TransparentTransmissionType的文档

    Returns void

registInfoReceiver

  • en

    Register a callback to receive heart beat information.

    zh

    注册回调以接收心跳信息

    example
    netease.yidun.yidunService.registInfoReceiver((type, info) => {
      if (type === netease.yidun.NetHeartBeatInfoType.HeartBeat) {
        // This heart beat type will only triggered on Android.
        // 该类型的心跳信息仅会在Android下触发。
        cc.log('Receive heart beat:', info);
      } else if (type === netease.yidun.NetHeartBeatInfoType.EncHeartBeat) {
        cc.log('Receive heart beat in encrypted form:', info);
        cc.log('You need sending it to server for decryption');
      } else if (type === netease.yidun.NetHeartBeatInfoType.CheatInfo) {
        // This heart beat type will only triggered on Android.
        // 该类型的心跳信息仅会在Android下触发。
        cc.log('Receive cheat info:', info);
      }
    });
    

    Parameters

    • infoReceiver: InfoReceiver

      En: The callback to receive heart beat information, please see the documentation of InfoReceiver and NetHeartBeatInfoType for detail. ID. Zh: 接收心跳信息的回调,详细请查看InfoReceiver和NetHeartBeatInfoType的文档

    Returns void

registerTouchEvent

  • registerTouchEvent(gameplayId: number, sceneId: number): void
  • en

    Start collecting click events related data to detect click simulation. Only supported on Android, will be ignored if called on non-Android.

    zh

    开始采集点击事件相关数据以检测模拟点击。仅支持Android,在非Android系统下调用会被忽略

    en

    NOTE: This function need separate payment, only use this function if you have strong demand for detecting click simulation cheating.

    zh

    注:该功能是单独付费功能,非强烈需要挖掘模拟点击类外挂的游戏,不需要接入

    example
    netease.yidun.yidunService.registerTouchEvent(123, 456);
    

    Parameters

    • gameplayId: number

      En: Gameplay ID. Zh: 玩法ID

    • sceneId: number

      En: Scene ID. Zh: 场景ID

    Returns void

safeComm

  • safeComm(inputData: string, algType: number, dec: boolean): string
  • en

    The encrypt/decrypt interface of secure communication protocol, only supported on Android, will be ignored if called on non-Android.

    zh

    安全通信协议的加密解密接口,仅支持Android,在非Android系统下调用会被忽略。

    example
    netease.yidun.yidunService.safeComm('test', 0, false);
    netease.yidun.yidunService.safeComm(encryptedData, 0, true);
    

    Parameters

    • inputData: string

      En: The data for encryption or decryption (determinted by dec param). Zh: 待加密或者解密的数据(由dec参数决定)

    • algType: number

      En: The type of the algorithm, currently passing 0. Zh: 算法标识,目前传0

    • dec: boolean

      En: If false, encrypt the data, if true, decrypt the data. Zh: 如果为假,加密数据,如果为真,解密数据

    Returns string

setRoleInfo

  • setRoleInfo(roleId: string, roleName: string, roleAccount: string, roleServer: string, serverId: number, gameJson: string): void
  • en

    Set the information of the logged-in user. After setting, the character ID and other information will be associated with the anti-cheat data and device information during data processing, which can obtain the malicious player's cheat information in real time, and the game can use the corresponding data to accurately punish the malicious player.

    zh

    设置登录用户的信息,设置后,数据处理时会将角色ID等信息与反外挂数据、设备信息关联,能实时获取恶意玩家使用外挂情况,游戏可通过相应数据对恶意玩家进行精准打击

    en

    NOTE: Regarding the data forwarding domain name/IP/port (see the gameJson parameter), after setting, when fail to send the data to the Yidun server, it will continue to send the data to the game server. For domain name and IP, you can choose to set one of them or both of them, the port is defaulted to 80. Before setting these fields, you need to contact with Yidun technicians. Try to pass these fields at the beginning, and set up server forwarding later. Data forwarding will only be performed after the failure to send to the Yidun server.

    zh

    注:关于数据转发域名/IP/端口(见gameJson参数),设置之后,当数据发送到易盾后端失败后,会继续向游戏服务端发送数据,由游戏方服务端转发到易盾后端.域名和IP可以选择设置一个或者都设置,端口默认使用80。在设置这些字段前需要和易盾技术人员确定。尽量默认接入的时候带上,之后有需要再搭建服务端转发,数据转发只会在发送到易盾服务端失败后才会进行

    example
    const roleId = '123456';
    const roleName = '易小盾';
    const roleAccount = 'yd@163.com';
    const roleServer = '游戏测试服';
    const gameJson = {
      GameVersion: '1.0.1',
      AssetVersion: '1.0.1',
      TransHost: 'test.163.com',
      TransIP: '8.8.8.8',
      TransPort: 80,
    };
    netease.yidun.yidunService.setRoleInfo(
      roleId,
      roleName,
      roleAccount,
      roleServer,
      JSON.stringify(gameJson)
    );
    // gameJson.GameVersion En: Game version. Zh: 游戏版本
    // gameJson.AssetVersion En: Assets version. Zh: 资源文件版本
    // gameJson.TransHost En: The domain name to forward anti-cheat data when the Yidun server is unreachable. Zh: 当易盾网络不通时,反外挂数据转发域名地址
    // gameJson.TransIP En: The IP to forward anti-cheat data when the Yidun server is unreachable. Zh: 当易盾网络不通时,反外挂数据转发IP
    // gameJson.TransPort En: The port to forward anti-cheat data when the Yidun server is unreachable. Zh: 当易盾网络不通时,反外挂数据转发端口
    

    Parameters

    • roleId: string

      En: Role ID, required. Zh: 角色ID,必填

    • roleName: string

      En: Role name, can be empty string. Zh: 角色名称,可填空字符串

    • roleAccount: string

      En: Role account, can be empty string. Zh: 角色账号,可填空字符串

    • roleServer: string

      En: Role server, can be empty string. Zh: 角色服务器

    • serverId: number

      En: Server ID, only used on Android, can be number zero if you don't need it. Zh: 所属服务器ID,仅在Android下使用,不用可填数字0

    • gameJson: string

      En: Additional upload information. Zh: 额外上传的信息

    Returns void

successOpportunityComes

  • successOpportunityComes(roleId: string, roleName: string, roleAccount: string, roleServer: string, reportDesc: string, verificationSpan: number, reportType: ReportType): void
  • en

    Reporting system, only supported on iOS, will be ignored if called on non-iOS. Used in the scenario: player A found that player B may cheating, player A then use the reporting system to report this information.

    zh

    举报系统,仅支持iOS,在非iOS系统下调用会被忽略。用于玩家A发现玩家B存在使用外挂嫌疑,玩家A通过举报系统举报玩家B。

    example
    const roleId = '123456';
    const roleName = '易小盾';
    const roleAccount = 'yd@163.com';
    const roleServer = '游戏测试服';
    const reportDesc = '自瞄';
    const verificationSpan = 1;
    const reportType = netease.yidun.ReportType.Plug;
    netease.yidun.yidunService.successOpportunityComes(
      roleId,
      roleName,
      roleAccount,
      roleServer,
      reportDesc,
      verificationSpan,
      reportType
    );
    

    Parameters

    • roleId: string

      En: Role ID, required. Zh: 角色ID,必填

    • roleName: string

      En: Role name, can be empty string. Zh: 角色名称

    • roleAccount: string

      En: Role account, can be empty string. Zh: 角色账号

    • roleServer: string

      En: Role server, can be empty string. Zh: 角色服务器

    • reportDesc: string

      En: Report description. Zh: 举报描述

    • verificationSpan: number

      En: The time span for query (in hours), the maximum is 24 hours, it is recommended to set to 1. Zh: 查询时间维度,以小时为单位,最大为24小时,建议设置为1

    • reportType: ReportType

      En: Report type, please see the documentation of ReportType for detail. Zh: 举报类型,详细请查看ReportType的文档

    Returns void

unregistInfoReceiver

  • en

    Unregister the callback registered by registInfoReceiver.

    zh

    取消registInfoReceiver注册过的回调

    example
    const infoReceiver = (type, info) => {
      if (type === netease.yidun.NetHeartBeatInfoType.HeartBeat) {
        // This heart beat type will only triggered on Android.
        // 该类型的心跳信息仅会在Android下触发。
        cc.log('Receive heart beat:', info);
      } else if (type === netease.yidun.NetHeartBeatInfoType.EncHeartBeat) {
        cc.log('Receive heart beat in encrypted form:', info);
        cc.log('You need sending it to server for decryption');
      } else if (type === netease.yidun.NetHeartBeatInfoType.CheatInfo) {
        // This heart beat type will only triggered on Android.
        // 该类型的心跳信息仅会在Android下触发。
        cc.log('Receive cheat info:', info);
      }
    };
    netease.yidun.yidunService.registInfoReceiver(infoReceiver);
    netease.yidun.yidunService.unregistInfoReceiver(infoReceiver);
    

    Parameters

    • infoReceiver: InfoReceiver

      En: The registered callback. Zh: 注册过的回调

    Returns void

unregisterTouchEvent

  • unregisterTouchEvent(): void
  • en

    Stop collecting click events related data. Only supported on Android, will be ignored if called on non-Android.

    zh

    停止采集点击事件相关数据。仅支持Android,在非Android系统下调用会被忽略

    example
    netease.yidun.yidunService.unregisterTouchEvent();
    

    Returns void

whetherWeatherPicked

  • whetherWeatherPicked(): Uint8Array
  • en

    Manually transparent transmission, only supported on iOS, will return an empty Uint8Array if called on non-iOS. You can get the data and combine the data with other encrypted data, then send the data to the game server and let the game server transmit the data to Yidun server.

    zh

    自助式透传,仅支持iOS,在非iOS系统下调用会返回空的Uint8Array。游戏⽅⾃⾏选择获取数据的时机。建议将数据合并到其他加密数据中,发送到游戏服务器,通过请求发送到易盾服务器

    Returns Uint8Array

Generated using TypeDoc