fcr-core
Version:
Core APIs for building online scenes
286 lines (285 loc) • 8.87 kB
TypeScript
import { FcrError } from '..';
import { FcrRoomJoinOptionsSchema } from '../schema';
import { FcrCloudRecordingConfig, FcrLiveStreamingConfig, FcrLiveStreamingLayoutType, FcrLiveStreamingState, FcrMessage, FcrNetworkQualityEvent, FcrNetworkStats, FcrRecordingState, FcrRoomInfo, FcrRoomJoinSnapshotOptions, FcrRoomPropertiesDeletedEvent, FcrRoomPropertiesUpdatedEvent, FcrRoomRouteSwitchEvent, FcrRoomSchedule, FcrRoomState } from '../type';
import { FcrChatRoomControl } from './chatroom-control/type';
import { FcrInterpreterControl } from './interpreter-control/types';
import { FcrPrivilegeControl } from './privilege-control/type';
import { FcrRoomConnectorControl } from './room-connector-control/type';
import { FcrRoomSessionControl } from './room-session/type';
import { FcrStreamControl } from './stream-control/type';
import { FcrUserControl, FcrUserRole } from './user-control/type';
import { FcrAbilityControl } from './ability-control/type';
import { FcrSharingControl } from './sharing-control/type';
export interface FcrBaseRoomControl {
/**
* Gets the user control.
*/
getUserControl(): FcrUserControl;
/**
* Gets the stream control.
*/
getStreamControl(): FcrStreamControl;
/**
* Gets the room session control.
*/
getRoomSessionControl(): FcrRoomSessionControl;
/**
* Gets the chat room control.
*/
getChatRoomControl(): FcrChatRoomControl;
/**
* Gets the privilege control.
*/
getPrivilegeControl(): FcrPrivilegeControl;
/**
* Gets the room connector control.
*/
getRoomConnectorControl(): FcrRoomConnectorControl;
/**
* Gets the ability control.
*/
getAbilityControl(): FcrAbilityControl;
/**
* Gets the sharing control.
*/
getSharingControl(): FcrSharingControl;
/**
* Gets the room ID.
*/
getRoomInfo(): FcrRoomInfo | undefined;
/**
* Gets the room schedule.
*/
getRoomSchedule(): FcrRoomSchedule | undefined;
/**
* Joins the room.
* @param options
*/
join(options: FcrRoomJoinSnapshotOptions): Promise<void>;
join(options: FcrRoomJoinOptions): Promise<void>;
/**
* Leaves the room.
*/
leave(): Promise<void>;
/**
* Starts the room.
*/
start(): Promise<void>;
/**
* Ends the room.
*/
end(): Promise<void>;
/**
* Closes the room.
*/
close(): Promise<void>;
/**
* Gets the room state.
*/
getRoomState(): FcrRoomState;
/**
* Gets the coordinated timestamp of the room.
*/
getSyncTimestamp(): number;
/**
* Gets the room properties.
*/
getRoomProperties(): Record<string, unknown>;
/**
* Gets the room properties by key path.
* @param keyPath
*/
getRoomPropertiesByKeyPath(keyPath: string): unknown;
/**
* Updates the room properties.
* @param properties
* @param cause
*/
updateRoomProperties(properties: Record<string, unknown>, cause?: Record<string, unknown>): Promise<void>;
/**
* Updates the increment room properties.
* @param increments
* @param cause
*/
updateIncrementRoomProperties(increments: Record<string, number>, cause?: Record<string, unknown>): Promise<void>;
/**
* Deletes the room properties.
* @param keyPaths
* @param cause
*/
deleteRoomProperties(keyPaths: string[], cause?: Record<string, unknown>): Promise<void>;
/**
* Starts the cloud recording.
* @param config
*/
startCloudRecording(config: FcrCloudRecordingConfig): Promise<void>;
/**
* Pauses the cloud recording.
*/
pauseCloudRecording(): Promise<void>;
/**
* Resumes the cloud recording.
*/
resumeCloudRecording(): Promise<void>;
/**
* Stops the cloud recording.
*/
stopCloudRecording(): Promise<void>;
/**
* Gets the state of the live streaming.
*/
getLiveStreamingState(): FcrLiveStreamingState;
/**
* Gets the config of the live streaming.
*/
getLiveStreamingConfig(): FcrLiveStreamingConfig | undefined;
/**
* Starts the live streaming.
* @param data
*/
startLiveStreaming(data: FcrLiveStreamingConfig): Promise<void>;
/**
* Updates the layout of live streaming.
* @param layoutType
*/
updateLiveStreamingLayout(layoutType: FcrLiveStreamingLayoutType): Promise<void>;
/**
* Stops the live streaming.
*/
stopLiveStreaming(): Promise<void>;
/**
* Gets the state of the cloud recording.
*/
getCloudRecordingState(): FcrRecordingState;
/**
* Sends a message to the room.
* @param payload
* @param guaranteedDelivery
*/
sendRoomMessage(payload: Record<string, unknown>, guaranteedDelivery?: boolean): Promise<void>;
/**
* Check the room is host key enabled.
*/
isHostKeyEnabled(): boolean;
/**
* Adds an observer to the room.
* @param observer
*/
addObserver(observer: FcrRoomObserver): void;
/**
* Removes the observer from the room.
* @param observer
*/
removeObserver(observer: FcrRoomObserver): void;
}
export interface FcrMainRoomControl extends FcrBaseRoomControl {
getInterpreterControl(): FcrInterpreterControl;
enableWaitingRoom(enable: boolean): Promise<void>;
moveToWaitingRoomByUserIds(userIds: string[]): Promise<void>;
moveToWaitingRoomByUserRoles(): Promise<void>;
}
export interface FcrSubRoomControl extends FcrBaseRoomControl {
}
export interface FcrWaitingRoomControl extends FcrBaseRoomControl {
moveToMainRoomByUserIds(userIds: string[]): Promise<void>;
moveToMainRoomByUserRoles(userRoles: FcrUserRole[]): Promise<void>;
}
export interface FcrJoinBeforeHostWaitingRoomControl extends FcrBaseRoomControl {
}
export type FcrRoomJoinOptions = FcrRoomJoinOptionsSchema;
export type FcrRoomConfig = {
roomId: string;
};
export type FcrRoomObserver = {
/**
* Callback when join room success.
* @param roomId
* @returns
*/
onJoinRoomSuccess?: (roomId: string) => void;
/**
* Callback when join room failure.
* @param roomId
* @param error
* @returns
*/
onJoinRoomFailure?: (roomId: string, error: FcrError) => void;
/**
* Callback to receive the room message.
* @param roomId
* @param message
* @returns
*/
onRoomMessageReceived?: (roomId: string, message: FcrMessage) => void;
/**
* Callback to receive the room state updated event.
* @param roomId
* @param state
* @returns
*/
onRoomStateUpdated?: (roomId: string, state: FcrRoomState) => void;
/**
* Callback to receive the cloud recording state updated event.
* @param roomId
* @param state
* @returns
*/
onCloudRecordingStateUpdated?: (roomId: string, state: FcrRecordingState) => void;
/**
* Callback to receive the room properties updated event.
* @param roomId
* @param event
* @returns
*/
onRoomPropertiesUpdated?: (roomId: string, event: FcrRoomPropertiesUpdatedEvent) => void;
/**
* Callback to receive the room properties deleted event.
* @param roomId
* @param event
* @returns
*/
onRoomPropertiesDeleted?: (roomId: string, event: FcrRoomPropertiesDeletedEvent) => void;
/**
* Callback to receive the network quality updated event.
* @param roomId
* @param event
*/
onNetworkQualityUpdated?(roomId: string, event: FcrNetworkQualityEvent): void;
/**
* Callback to receive the network stats updated event.
* @param roomId
* @param stats
*/
onNetworkStatsUpdated?(roomId: string, stats: FcrNetworkStats): void;
/**
* Callback to receive the live streaming state updated event.
* @param roomId
* @param state
* @param url
*/
onLiveStreamingStateUpdated?(roomId: string, state: FcrLiveStreamingState, url?: string, reason?: FcrLiveStreamingStateUpdatedReason): void;
/**
* Callback to receive the room routing changed event.
* @param event
*/
onRoomRouteSwitched?(event: FcrRoomRouteSwitchEvent): void;
};
export type FcrWaitingRoomObserver = FcrRoomObserver & {};
export type FcrJoinBeforeHostWaitingRoomObserver = FcrRoomObserver & {};
export type FcrMainRoomObserver = FcrRoomObserver & {};
export type FcrLocalUserWaitingRoomMovedEvent = FcrRoomPropertiesUpdatedEvent;
export declare enum FcrRoomType {
Mainroom = 11,
Waitingroom = 102,
Subroom = 101,
Interpreterroom = 103,
JoinBeforeHostWaitingRoom = 104
}
export declare enum FcrLiveStreamingStateUpdatedReason {
USERSTOPPED = 1,
HOSTCHANGED = 2
}
export declare enum FcrLineType {
SINGLE_ROW = 1,
MULTI_ROW = 2
}