@anyrtc/whiteboard-with-ui
v0.0.1
Published
This is an white board SDK include ui, simple ot use, you can visit anyrtc.io get app token.
Downloads
1
Readme
anyrtc-whiteboard
anyRTC平台画板SDK是一款跨平台轻量级的白板SDK,易用、实时。
DEMO
前往体验
Installation
Using npm:
# 更新npm
$ npm i -g npm
# 安装SDK
$ npm i -S anyrtc-whiteboard socket.io-client
In Node.js:
import { Board } from 'anyrtc-whiteboard';
Useage
获取开发者信息
- 前往anyRTC 云平台获取开发者信息,并创建一个app应用。
创建Canvas
<canvas id="myCanvas" width="640" height="480"></canvas>
初始化实例
import Board from 'anyrtc-whiteboard';
var board = new Board(document.getElementById("myCanvas"));
initEngineWithAnyRTCInfo - 连接画板服务
//前往anyrtc平台获取
var DEV_ID = "";//开发者Id
var APP_ID = "";//应用的appId
var APP_KEY = "" ;//应用的appKey
var APP_TOKEN = "";//应用的appToken
var APP_DOMAIN = "";//网站域名-(上线必填,开发可以为空)
//初始化anyRTC引擎
board.initEngineWithAnyRTCInfo(DEV_ID, APP_ID, APP_KEY, APP_TOKEN, APP_DOMAIN).then(res => {
if (res.code === 0) {//初始化成功
//Do something
} else {
//连接不成功
}
}).catch(err => {
});
initWithRoomID - 初始化画板
在initEngineWithAnyRTCInfo
成功之后,初始化画板
//前往
var fileId = "";//文件ID(保证唯一)
var anyRTCId = "";//房间号(保证唯一)
var userId = "";//用户id(保证唯一)
var backgroundList= [] ;//背景图片
//连接服务
board.initWithRoomID(fileId, anyRTCId, userId, backgroundList).then(res => {
if (res.code === 0) {
//连接成功
} else {
//连接不成功
}
});
监听回调
//监听画板变化
board.on("onBoardPageChange", (currentPage, totalPage, backgroundUrl, backgroundList) => {
console.log("当前画板页数", currentPage);
console.log("画板总页数Index", totalPage);
console.log("当前画板背景URL", backgroundUrl);
console.log("所有画板背景列表", backgroundList);
});
//画板被销毁
board.on("onBoardDestroy", () => {
});
//监听画板错误
board.on("onBoardError", code => {
//详情请参考错误码
});
错误码
|code | Desciption | |----------|:-------------:| |AnyRTCBoardCodeParameterError |参数为空或者参数错误| |AnyRTCBoardCodeNoNet | 当前无网络| |AnyRTCBoardCodeSessionPastDue | Session已过期| |AnyRTCBoardCodeDeveloperInfoError | 开发者信息错误| |AnyRTCBoardCodeDeveloperArrearage | 账号欠费| |AnyRTCBoardCodeDeveloperNotOpen | 该功能未开通| |AnyRTCBoardCodeDatabaseError | 数据库异常| |AnyRTCBoardCodeBackgroundListIsNull | 背景图片队列为空 |
技术支持
加QQ技术咨询群:580477436 (一群) 554714720 (二群)
欢迎加入anyRTC社区 和我们一起探讨WebRTC技术以及解决集成问题。