Room
is an instance object of a real-time room, constructed by the instance of WhiteWebSdk
(refer to 《Constructing Room and Player Objects》). It implements the Displayer
interface (refer to 《Displayer》), which is defined as follows.
interface Room extends Displayer {
readonly uuid: string;
readonly session?: string;
readonly roomToken: string;
readonly phase: RoomPhase;
readonly state: RoomState;
readonly isWritable: boolean;
readonly canUndoSteps: number;
readonly canRedoSteps: number;
disableDeviceInputs: boolean;
disableEraseImage: boolean;
disableSerialization: boolean;
timeDelay: number;
setWritable(isWritable: boolean): Promise<void>;
setGlobalState(modifyState: Partial<GlobalState>): GlobalState;
setMemberState(modifyState: Partial<MemberState>): MemberState;
setViewMode(viewMode: ViewMode): void;
setScenePath(scenePath: string): void;
setSceneIndex(index: number): void;
dispatchMagixEvent(event: string, payload: any): void;
putScenes(path: string, scenes: ReadonlyArray<SceneDefinition>, index?: number): void;
cleanCurrentScene(retainPpt?: boolean): void;
removeScenes(path: string): void;
moveScene(originalPath: string, targetPath: string): void;
insertImage(imageInfo: ImageInformation): void;
completeImageUpload(uuid: string, src: string): void;
duplicate(): void;
copy(): void;
paste(): void;
undo(): number;
redo(): number;
delete(): void;
pptNextStep(): void;
pptPreviousStep(): void;
disconnect(): Promise<void>;
}
The uuid
of the room is used to uniquely identify the room.
The uuid
of the current Session of the room. Will be reported as a log field (if the automatic log reporting function is enabled). If the connection to the server has not been established yet, it is undefined
.
Room Token, which is the field passed in when joining the room.
The room status, and its type RoomPhase
is defined as follows.
enum RoomPhase {
// connecting
Connecting = "connecting",
// connection succeeded
Connected = "connected",
// Reconnecting
Reconnecting = "reconnecting",
// Disconnecting
Disconnecting = "disconnecting",
// Disconnected
Disconnected = "disconnected",
}
Read 《Real-time Room State Management》 to learn more.
Business state, its type is RoomState
. Read 《Business State Management of Room and Playback》, 《Room Business State Management》 to understand more.
Whether it is currently "writable".
Steps can be undone. At this moment, how many times can the room.undo()
method be called.
Steps can be redone. At this moment, how many times can the room.redo()
method be called.
Whether to prohibit device input. That is to use the mouse, keyboard, touch screen to operate teaching aids. Can be modified.
Whether to prohibit the eraser tool to erase the pictures on the whiteboard (does not affect the PPT background in the whiteboard). Can be modified.
Whether to prohibit the following methods (the default value is true
). Can be modified.
room.redo
room.undo
room.duplicate
room.copy
room.paste
The version of
white-web-sdk
of everyone in the room must be at least2.9.3
, then the value can be set tofalse
. Anyone in the room setting the value tofalse
will cause the user front-end in the room lower than2.9.3
to report an error and not work normally.
Actively delay the received remote message, the unit is milliseconds, the default value is 0
. Setting this value to a number greater than 0
can artificially cause an effect similar to network delay. Can be modified.
setWritable(isWritable: boolean): Promise<void>;
Modify the value of room.isWritable
. This operation will initiate a request to the server, so a Promise
object will be returned. Note that the abnormal flow is handled by .catch()
, because the request may be rejected by the server or fail.
setGlobalState(modifyState: Partial<GlobalState>): GlobalState;
Used to modify the globalState
field of the room. You can modify specific fields in the following ways.
room.setGlobalState({
foobar: "hello world",
});
You can also delete a field by setting it to undefined
.
room.setGlobalState({
foobar: undefined,
});
setMemberState(modifyState: Partial<MemberState>): MemberState;
Used to modify the memberState
field of the room. You can modify specific fields in the following ways.
room.setMemberState({
foobar: "hello world",
});
You can also delete a field by setting it to undefined
.
room.setMemberState({
foobar: undefined,
});
setViewMode(viewMode: ViewMode): void;
Modify the value of room.state.broadcastState.mode
of the room. Will change the perspective mode of yourself or other people in the room.
setScenePath(scenePath: string): void;
Modifying the current scene address will switch the scene of the current room.
setSceneIndex(index: number): void;
Modifying the index number of the current scene will switch the scene of the current room.
dispatchMagixEvent(event: string, payload: any): void;
Broadcast custom events to the room. Among them, the first parameter event
is the name of the event, and other members in the room can register to listen for the event through it. The second parameter payload
is the load, which can be any type of value, and can be designed according to the specific business.
putScenes(path: string, scenes: ReadonlyArray<SceneDefinition>, index?: number): void;
Insert a scene in the room. Refer to 《Insert New Scene|Scene Management》.
removeScenes(path: string): void;
Delete scenes in the room. Refer to 《Delete Scene|Scene Management》.
moveScene(originalPath: string, targetPath: string): void;
Move the scene in the room. Refer to 《Mobile Scene|Scene Management》.
cleanCurrentScene(retainPpt?: boolean): void;
Clean up all content in the current scene. The first parameter retianPpt
indicates whether to keep the PPT background without being cleaned up. The default value is true
.
insertImage(imageInfo: ImageInformation): void;
Insert a picture in the current scene. The parameter type is ImageInformation
, which is defined as follows.
type ImageInformation = {
// uuid of the picture
readonly uuid: string;
// The x-axis coordinate of the center point of the inserted picture in the world coordinate system
readonly centerX: number;
// The y-axis coordinate of the center point of the inserted picture in the world coordinate system
readonly centerY: number;
// The width of the inserted picture in the world coordinate system
readonly width: number;
// The height of the inserted picture in the world coordinate system
readonly height: number;
// Whether to lock the picture so that it cannot be erased or selected by the selection tool
readonly locked: boolean;
};
This operation often needs to be used in conjunction with room.completeImageUpload
. For specific examples, please refer to 《Insert Picture|Teaching Tools》.
completeImageUpload(uuid: string, src: string): void;
Set up image resources. The first parameter uuid
is the unique identifier of the image, which should be the same as the uuid
field passed in in room.insertImage
. The second parameter src
is the URL of the image resource. For specific examples, please refer to 《Insert Picture|Teaching Tools》.
Copy all the key components selected by the currently selected tool. It can be called only when room.disableSerialization
is false
.
Copy all the key components selected by the current selection tool. It can be called only when room.disableSerialization
is false
.
Paste the last copied component. It can be called only when room.disableSerialization
is false
.
Undo the last action. It can be called only when room.disableSerialization
is false
.
Redo the last action. It can be called only when room.disableSerialization
is false
.
Delete all components selected by the current selection tool.
pptNextStep(): void;
PPT scrolls to the next page. If there is no animation in the current PPT, switch to the scene with index +1, if there is an animation, then play the next animation.
pptPreviousStep(): void;
PPT turns the page to the previous page. If there is no animation in the current PPT, switch to the scene with index -1; if there is an animation, switch to the state where the previous animation has finished playing.
disconnect(): Promise<void>;
Disconnect the room. This is an asynchronous method and will return a Promise
object.