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
👉 立即开发。
文章介绍了P2PSDK的初始化、反初始化过程,以及检查P2P连接、建立和断开设备连接的方法,强调了版本要求和回调函数的使用。
&spm=1001.2101.3001.5002&articleId=136943500&d=1&t=3&u=60b6d0a3e9d74016a595077b6c2ded36)
576

被折叠的 条评论
为什么被折叠?



