Room
Whiteboard Web SDK 2.16.59 公开 interface。
export declare interface Room extends Displayer
Properties
uuid
readonly uuid: string;
房间的 ``uuid``,用于唯一标识该房间。
uid
readonly uid: string;
加入该房间的用户的唯一标识符
session
readonly session: string;
房间当前的 Session 的 ``uuid``。会被上报作为日志字段(如果开启了自动日志上报功能)。如果当前尚未与服务器建立连接,则为 ``undefined``。
roomToken
readonly roomToken: string;
房间 Token,即加入房间时传入的字段。
phase
readonly phase: RoomPhase;
房间连接所处的阶段
calibrationTimestamp
readonly calibrationTimestamp: number;
与服务器时钟校准后的当前时间戳,单位为毫秒
state
readonly state: RoomState;
业务状态 阅读 《房间与回放的业务状态管理》 、《房间业务状态管理》 以了解更多。
isWritable
readonly isWritable: boolean;
房间是否「可写」
canUndoSteps
readonly canUndoSteps: number;
可撤销步骤。即此时此刻,还可以调用多少次 ``room.undo()`` 方法。
canRedoSteps
readonly canRedoSteps: number;
可重做步骤。即此时此刻,还可以调用多少次 ``room.redo()`` 方法。
disableDeviceInputs
disableDeviceInputs: boolean;
是否禁止设备操作。 注意区分「只读模式」与「禁止设备操作」,具体参考进阶教程《禁止设备操作|禁止操作》。
disableEraseImage
disableEraseImage: boolean;
是否禁止橡皮擦除图片
disableSerialization
disableSerialization: boolean;
是否禁止如下方法(默认值是 ``true``)。可修改。
- ``room.redo``
- ``room.undo``
- ``room.duplicate``
- ``room.copy``
- ``room.paste`` 房间内所有人的 ``white-web-sdk`` 的版本必须不低于 ``2.9.3`` 时,才能将该值设为 ``false``。房间内任何一个人将该值设为 ``false``,都会导致房间内低于 ``2.9.3`` 的用户前端报错且不能正常使用。
timeDelay
timeDelay: number;
主动延迟接收的远端消息,单位是毫秒,默认值 ``0``。将该值设置成大于 ``0`` 的数字,可以人为造成类似网络时延的效果。可修改。
syncMode
syncMode: boolean;
默认情况下,所有同步消息会按比较平滑的速度处理,以此保证观感的流畅性。 如果设置此项为 ``true``,则所有消息一经收到立刻处理,从而保证同步的实时性。
useNativeClipboard
useNativeClipboard: boolean;
是否使用原生剪贴板。 设为 ``true`` 后,快捷键里的复制和粘贴将失效而使用原生 ``copy`` ``paste`` 事件。 此功能需要浏览器支持以及用户授予剪贴板权限,如果失败,将自动回退到虚拟剪贴板实现。
createInvisiblePlugin
createInvisiblePlugin<K extends string, A extends Object, MA extends Object, P extends InvisiblePlugin<A, MA>>(pluginClass: InvisiblePluginClass<K, A, MA, P>, attributes: A): Promise<InvisiblePlugin<A, MA>>;
callbacks
readonly callbacks: Callbacks<CALLBACKS>;
observerId
readonly observerId: number;
region
readonly region: string;
slice
readonly slice: string;
version
readonly version: string;
deviceType
readonly deviceType: DeviceType;
screenType
readonly screenType: ScreenType;
enableWriteNow
readonly enableWriteNow: boolean;
handToolKey
readonly handToolKey: string | undefined;
views
readonly views: Views;
useMobXState
readonly useMobXState: boolean;
useMultiViews
readonly useMultiViews: boolean;
handToolActive
handToolActive: boolean;
disableOthersSelectingBox
disableOthersSelectingBox: boolean;
disableCameraTransform
disableCameraTransform: boolean;
commandWheelToZoom
commandWheelToZoom: boolean;
dynamicConfig
readonly dynamicConfig?: DynamicConfigSnapshot;
加入房间时完成求值的远端参数快照。
dynamicConfigState
readonly dynamicConfigState?: DynamicConfigState;
本次配置来源、运行时匹配和失败回退原因;不是配置文件原文。
Methods
setWritable
setWritable(isWritable: boolean): Promise<void>;
修改room.isWritable的值。 该操作会向服务器发起请求,因此会返回一个Promise对象。注意通过.catch()的方式处理异常流程,因为请求可能被服务器拒绝,或失败。
返回值
setGlobalState
setGlobalState(modifyState: Partial<GlobalState>): GlobalState;
用于修改房间的globalState的字段。可以通过如下方法修改特定字段。 @exampletypescript{"\n"}room.setGlobalState({"{"}{"\n"}{" "}foobar: "hello world",{"\n"}{"}"});{"\n"}也可以通过将某个字段置为undefined,来删掉该字段。 @exampletypescript{"\n"}room.setGlobalState({"{"}{"\n"}{" "}foobar: undefined,{"\n"}{"}"});{"\n"}
返回值
setMemberState
setMemberState(modifyState: Partial<MemberState>): MemberState;
用于修改房间的memberState的字段。可以通过如下方法修改特定字段。 @exampletypescript{"\n"}room.setMemberState({"{"}{"\n"}{" "}foobar: "hello world",{"\n"}{"}"});{"\n"}@example 也可以通过将某个字段置为undefined,来删掉该字段。typescript{"\n"}room.setMemberState({"{"}{"\n"}{" "}foobar: undefined,{"\n"}{"}"});{"\n"}
返回值
setViewMode
setViewMode(viewMode: ViewMode): void;
修改房间的 room.state.broadcastState.mode 的值。会改变自己或房间内其他人的视角模式。返回值
setScenePath
setSceneIndex
syncBlockTimestamp
stopBlockTimestamp
dispatchMagixEvent
dispatchMagixEvent(event: string, payload: any): void;
向房间内广播自定义事件。其中,第一参数event是事件的名称,房间内其他成员可以通过它注册监听事件。 第二参数payload是负载,可以是任意类型的值,可根据具体业务自行设计。
返回值
putScenes
putScenes(path: string, scenes: ReadonlyArray<SceneDefinition>, index?: number): void;
在房间中插入场景。参考《插入新场景|场景管理》。 @param path 想要插入到的场景组地址 @param scenes 场景描述列表 @param index 从哪个索引所在位置插入
返回值
cleanCurrentScene
cleanCurrentScene(retainPpt?: boolean): void;
清理当前场景内所有内容。第一参数retianPpt@param retainPpt 表明是否保留 PPT 背景不被清理,默认值是true
返回值
removeScenes
moveScene
exportScene
exportScene(scenePath: string): Promise<Blob>;
导出特定场景路径的板书内容(包含 ppt 内容),可以直接保存为二进制文件(废弃)。 @param scenePath 需要导出场景的路径,必须是ScenePathType为page的路径。
返回值
importScene
importScene(dir: string, payload: Blob, overrideName?: string): Promise<SceneDefinition>;
导入之前导出的板书内容(废弃)。 @param dir 当前板书内容,需要插入的场景目录位置,该目录的 ScenePathType 可以为空,但是不能为 conflict,这回导致该路径无法成功插入新场景。 @param payload 二进制文件的文件句柄指向 @param overrideName 不使用文件内的 name,改为覆盖指定场景 @returns 板书内部的内容,一定会存在 name 字段,该字段不可更改;最后插入的板书路径为 dir + name。如果想修改板书路径,可以再调用 mvScene API 进行修改。
返回值
insertImage
lockImage
lockImage(uuid: string, locked: boolean): void;
改变图片的锁定状态。若图片被锁定,则无法被框选、无法被拖动、无法被改变大小 @param uuid 图片的 UUID
返回值
completeImageUpload
getImagesInformation
getImagesInformation(scenePath: string): ImageInformation[];
导出特定场景的图片信息,注意这些信息可能与插入时填写的不同。 @param scenePath 需要导出图片信息的场景路径,必须是ScenePathType为page的路径。
返回值
insertPlugin
removePlugin
updatePlugin
getPluginAttributes
getPluginRectangle
duplicate
copy
paste
undo
redo
clearUndoHistory
clearUndoHistory(includeRedo?: boolean): void;
清空可撤回的历史记录, 令canUndoSteps立刻等于 0。 @param includeRedo 是否同时清空重做的记录,默认值是true
返回值
delete
lockImages
moveSelectedComponentsToTop
moveSelectedComponentsToBottom
insertText
insertText(x: number, y: number, textContent?: string): Identifier;
在指定位置插入文字 @param x 第一个字的的左侧边中点,世界坐标系中的 x 坐标 @param y 第一个字的的左侧边中点,世界坐标系中的 y 坐标 @param textContent 初始化文字的内容,不传则为空 @returns 该文字的标识符
返回值
updateText
updateText(identifier: Identifier, textContent: string): void;
编辑指定文字的内容
@param identifier 文字的标识符。为 insertText() 的返回值。
@param textContent 文字要改成的内容返回值
updateSelectedText
pptNextStep
pptPreviousStep
disconnect
disconnect(options?: RoomDisconnectOptions): Promise<void>;
令房间断开连接。这是一个异步方法,会返回 Promise 对象。返回值
uploadLocalLogs
uploadLocalLogs(): Promise<WhiteLocalLogUploadResult>;
上传本地日志;日志运行时和上传开关均需可用,enabled/ enabledUpload 未设置为 false 时默认尝试开启。通过返回结果和状态事件观察上传。
主动上传当前房间关联的本地日志。
返回值
refreshViewSize
setCameraBound
createScenesCallback
createScenesCallback(path: string, callbacks?: Partial<ScenesCallbacks>): ScenesCallbacksNode | null;
返回值
memberState
moveCamera
moveCameraToContain
moveCameraToContain(rectangle: Rectangle & Readonly<{
animationMode?: AnimationMode;
}>): void;
返回值
bindHtmlElement
getInvisiblePlugin
getInvisiblePlugin<A extends Object, MA extends Object>(kind: string): InvisiblePlugin<A, MA> | null;
返回值
convertToPointInWorld
convertToPointInWorld(point: {
x: number;
y: number;
}): {
x: number;
y: number;
};
返回值
scenePreview
scenePreview(scenePath: string, div: HTMLElement, width?: number, height?: number, engine?: RenderEngine): void;
返回值
generateScreenshot
generateScreenshot(scenePath?: string, width?: number, height?: number): Promise<string>;
返回值
fillSceneSnapshot
fillSceneSnapshot(scenePath: string, div: HTMLElement, width?: number, height?: number, engine?: RenderEngine): void;
返回值
screenshotToCanvas
screenshotToCanvas(context: CanvasRenderingContext2D, scenePath: string, width: number, height: number, camera: Camera, ratio?: number): void;
返回值
screenshotToCanvasAsync
screenshotToCanvasAsync(context: CanvasRenderingContext2D, scenePath: string, width: number, height: number, camera: Camera, ratio?: number, timeout?: number): Promise<void>;
返回值
getBoundingRect
addMagixEventListener
addMagixEventListener(event: string, listener: EventListener, options?: MagixEventListenerOptions): void;