p2p.downloadStream
P2P 下载数据流
需引入
P2PKit
,且在>=2.0.3
版本才可使用
Use in Ray
// @ray-js/ray >=1.3.15
import { p2p } from '@ray-js/ray';
const { downloadStream } = p2p;
参数
Object object
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
deviceId | string | 是 | 设备 id | |
albumName | string | 是 | albumName 和设备端约定字段 | |
jsonfiles | string | 是 | 下载的文件名称,eg: {"files":["filesname1", "filesname2", "filesname3" ]} | |
complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | |
success | function | 否 | 接口调用成功的回调函数 | |
fail | function | 否 | 接口调用失败的回调函数 |
函数定义示例
/**
* P2P下载数据流
*/
export function downloadStream(params: {
/** 设备id */
deviceId: string;
/** albumName 和设备端约定字段 */
albumName: string;
/** 下载的文件名称,eg: {"files":["filesname1", "filesname2", "filesname3" ]} */
jsonfiles: string;
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
complete?: () => void;
/** 接口调用成功的回调函数 */
success?: (params: null) => void;
/** 接口调用失败的回调函数 */
fail?: (params: {
errorMsg: string;
errorCode: string | number;
innerError: {
errorCode: string | number;
errorMsg: string;
};
}) => void;
}): void;
👉 立即免费领取开发资源,体验涂鸦 MiniApp 小程序开发。
p2p.queryAlbumFileIndexs
查询设备相册文件索引列表
需引入
P2PKit
,且在>=2.0.3
版本才可使用
Use in Ray
// @ray-js/ray >=1.3.15
import { p2p } from '@ray-js/ray';
const { queryAlbumFileIndexs } = p2p;
参数
Object object
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
deviceId | string | 是 | 设备 id | |
albumName | string | 是 | albumName 和设备端约定字段 | |
complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | |
success | function | 否 | 接口调用成功的回调函数 | |
fail | function | 否 | 接口调用失败的回调函数 |
object.success 回调参数
参数
Object res
属性 | 类型 | 说明 |
---|---|---|
count | number | 文件个数 |
items | array | 文件索引 |
object.fail 回调参数
参数
Object res
属性 | 类型 | 说明 |
---|---|---|
errorMsg | string | 插件错误信息 |
errorCode | string | 错误码 |
innerError | object | 插件外部依赖错误信息 {errorMsg: string, errorCode: string } |
函数定义示例
/**
* 查询设备相册文件索引列表
*/
export function queryAlbumFileIndexs(params: {
/** 设备id */
deviceId: string;
/** albumName 和设备端约定字段 */
albumName: string;
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
complete?: () => void;
/** 接口调用成功的回调函数 */
success?: (params: {
/** 文件个数 */
count: number;
/** 文件索引 */
items: ThingP2PAlbumFileIndex[];
}) => void;
/** 接口调用失败的回调函数 */
fail?: (params: {
errorMsg: string;
errorCode: string | number;
innerError: {
errorCode: string | number;
errorMsg: string;
};
}) => void;
}): void;
p2p.onSessionStatusChange
连接状态改变回调
需引入
P2PKit
,且在>=2.0.3
版本才可使用
Use in Ray
// @ray-js/ray >=1.3.15
import { p2p } from '@ray-js/ray';
const { onSessionStatusChange } = p2p;
参数
function callback
连接状态改变回调的回调函数
回调参数 Object res
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
deviceId | string | 是 | 设备 id | |
status | number | 是 | 状态值, 小于 0 为断开连接 |
函数定义示例
/**
* 连接状态改变回调
*/
export function onSessionStatusChange(
listener: (params: {
/** 设备id */
deviceId: string;
/** 状态值, 小于0为断开连接 */
status: number;
}) => void,
): void;
👉 立即免费领取开发资源,体验涂鸦 MiniApp 小程序开发。