ty.p2p.P2PSDKInit
P2P SDK 初始化
需引入
P2PKit
,且在>=0.0.1
版本才可使用
参数
Object object
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
userId | string | 是 | 用户id | |
complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | |
success | function | 否 | 接口调用成功的回调函数 | |
fail | function | 否 | 接口调用失败的回调函数 |
函数定义示例
/**
* P2P SDK 初始化
*/
export function P2PSDKInit(params: {
/** 用户id */
userId: string
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
complete?: () => void
/** 接口调用成功的回调函数 */
success?: (params: null) => void
/** 接口调用失败的回调函数 */
fail?: (params: {
errorMsg: string
errorCode: string | number
innerError: {
errorCode: string | number
errorMsg: string
}
}) => void
}): void
ty.p2p.deInitSDK
P2P SDK 反初始化
需引入
P2PKit
,且在>=0.0.1
版本才可使用
参数
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
👉 立即开发。
ty.p2p.isP2PActive
检查P2P连接
需引入
P2PKit
,且在>=2.0.3
版本才可使用
参数
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
ty.p2p.isP2PActiveSync
检查P2P连接同步方法
需引入
P2PKit
,且在>=2.0.3
版本才可使用ty.isP2PActive的同步版本
参数
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
ty.p2p.connectDevice
建立P2P连接
需引入
P2PKit
,且在>=0.0.1
版本才可使用
参数
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 connectDevice(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
ty.p2p.disconnectDevice
和设备断开连接
需引入
P2PKit
,且在>=0.0.1
版本才可使用
参数
Object object
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
deviceId | string | 是 | 设备id | |
complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | |
success | function | 否 | 接口调用成功的回调函数 | |
fail | function | 否 | 接口调用失败的回调函数 |
函数定义示例
/**
* 和设备断开连接
*/
export function disconnectDevice(params: {
/** 设备id */
deviceId: string
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
complete?: () => void
/** 接口调用成功的回调函数 */
success?: (params: null) => void
/** 接口调用失败的回调函数 */
fail?: (params: {
errorMsg: string
errorCode: string | number
innerError: {
errorCode: string | number
errorMsg: string
}
}) => void
}): void
👉 立即开发。