p2p.P2PSDKInit
P2P SDK 初始化
需引入
P2PKit
,且在>=2.1.0
版本才可使用。
在 ODM/v5.12.0 以上可以使用。
Use in Ray
// @ray-js/ray >=1.4.62
import { p2p } from '@ray-js/ray';
const { P2PSDKInit } = p2p;
参数
Object object
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | |
success | function | 否 | 接口调用成功的回调函数 | |
fail | function | 否 | 接口调用失败的回调函数 |
函数定义示例
/**
* P2P SDK 初始化
*/
export function P2PSDKInit(params: {
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
complete?: () => void;
/** 接口调用成功的回调函数 */
success?: (params: null) => void;
/** 接口调用失败的回调函数 */
fail?: (params: {
errorMsg: string;
errorCode: string | number;
innerError: {
errorCode: string | number;
errorMsg: string;
};
}) => void;
}): void;
👉 立即免费领取开发资源,体验涂鸦 MiniApp 小程序开发。
p2p.deInitSDK
P2P SDK 反初始化
需引入
P2PKit
,且在>=2.0.3
版本才可使用
Use in Ray
// @ray-js/ray >=1.3.15
import { p2p } from '@ray-js/ray';
const { deInitSDK } = p2p;
参数
Object object
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | |
success | function | 否 | 接口调用成功的回调函数 | |
fail | function | 否 | 接口调用失败的回调函数 |
函数定义示例
/**
* P2P SDK 反初始化
*/
export function deInitSDK(params?: {
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
complete?: () => void;
/** 接口调用成功的回调函数 */
success?: (params: null) => void;
/** 接口调用失败的回调函数 */
fail?: (params: {
errorMsg: string;
errorCode: string | number;
innerError: {
errorCode: string | number;
errorMsg: string;
};
}) => void;
}): void;
p2p.isP2PActive
检查 P2P 连接
需引入
P2PKit
,且在>=2.0.3
版本才可使用
Use in Ray
// @ray-js/ray >=1.3.15
import { p2p } from '@ray-js/ray';
const { isP2PActive } = p2p;
参数
Object object
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
deviceId | string | 是 | 设备 id | |
mode | number | 否 | 连接模式,0:INTERNET 1:LAN | |
timeout | number | 否 | 超时时长,单位:ms,设置 0 会设置成默认值,Internet:15000ms, Lan:3000ms | |
complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | |
success | function | 否 | 接口调用成功的回调函数 | |
fail | function | 否 | 接口调用失败的回调函数 |
函数定义示例
/**
* 检查P2P连接
*/
export function isP2PActive(params: {
/** 设备id */
deviceId: string;
/** 连接模式,0:INTERNET 1:LAN */
mode?: number;
/** 超时时长,单位:ms,设置0会设置成默认值,Internet:15000ms, Lan:3000ms */
timeout?: number;
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
complete?: () => void;
/** 接口调用成功的回调函数 */
success?: (params: null) => void;
/** 接口调用失败的回调函数 */
fail?: (params: {
errorMsg: string;
errorCode: string | number;
innerError: {
errorCode: string | number;
errorMsg: string;
};
}) => void;
}): void;
p2p.isP2PActiveSync
检查 P2P 连接同步方法
需引入
P2PKit
,且在>=2.0.3
版本才可使用
Use in Ray
// @ray-js/ray >=1.3.15
import { p2p } from '@ray-js/ray';
const { isP2PActiveSync } = p2p;
参数
Object object
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
deviceId | string | 是 | 设备 id | |
mode | number | 否 | 连接模式,0:INTERNET 1:LAN | |
timeout | number | 否 | 超时时长,单位:ms,设置 0 会设置成默认值,Internet:15000ms, Lan:3000ms |
函数定义示例
/**
* 检查P2P连接
*/
export function isP2PActiveSync(params: {
/** 设备id */
deviceId: string;
/** 连接模式,0:INTERNET 1:LAN */
mode?: number;
/** 超时时长,单位:ms,设置0会设置成默认值,Internet:15000ms, Lan:3000ms */
timeout?: number;
}): null;
👉 立即免费领取开发资源,体验涂鸦 MiniApp 小程序开发。