fcr-core
Version:
Core APIs for building online scenes
278 lines (277 loc) • 8.8 kB
TypeScript
import { FcrError, FcrStreamLatencyLevel } from '..';
import { FcrCloudRecordingConfig, FcrLiveStreamingConfig, FcrLiveStreamingLayoutType, FcrLiveStreamingState, FcrMessage, FcrNetworkQualityEvent, FcrNetworkStats, FcrRecordingState, FcrRoomInfo, FcrRoomJoinOptionsWithTicket, FcrRoomJoinSnapshotOptions, FcrRoomPropertiesDeletedEvent, FcrRoomPropertiesUpdatedEvent, FcrRoomSchedule, FcrRoomState, FcrStreamEncryptionConfig, FcrStreamJoinConfig, FcrUserRole } 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 } from './user-control/type';
import { FcrWhiteboardControl } from './whiteboard-control/types';
export interface FcrBaseRoomControl {
/**
* Gets the user control.
*/
getUserControl(): FcrUserControl;
/**
* Gets the whiteboard control.
*/
getBoardControl(): FcrWhiteboardControl;
/**
* 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 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>;
/**
* 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>;
joinWithTicket(options: FcrRoomJoinOptionsWithTicket): Promise<void>;
}
export interface FcrSubRoomControl extends FcrBaseRoomControl {
}
export interface FcrWaitingRoomControl extends FcrBaseRoomControl {
moveToMainRoomByUserIds(userIds: string[]): Promise<void>;
moveToMainRoomByUserRoles(userRoles: FcrUserRole[]): Promise<void>;
}
export type FcrRoomJoinOptions = {
userName: string;
userRole: FcrUserRole;
userProperties?: Record<string, unknown>;
roomToken: string;
streamLatency: FcrStreamLatencyLevel;
streamEncryptionConfig?: FcrStreamEncryptionConfig;
createStreamConfigs: FcrStreamJoinConfig[];
password?: string;
platform?: number;
};
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;
};
export type FcrWaitingRoomObserver = FcrRoomObserver & {
onLocalUserMovedToMainRoom?: (roomId: string, event: FcrLocalUserWaitingRoomMovedEvent) => void;
};
export type FcrMainRoomObserver = FcrRoomObserver & {
onLocalUserMovedToWaitingRoom?: (roomId: string, event: FcrLocalUserWaitingRoomMovedEvent) => void;
};
export type FcrLocalUserWaitingRoomMovedEvent = FcrRoomPropertiesUpdatedEvent;
export declare enum FcrRoomType {
Mainroom = 11,
Waitingroom = 102,
Subroom = 101,
Interpreterroom = 103
}
export declare enum FcrLiveStreamingStateUpdatedReason {
USERSTOPPED = 1,
HOSTCHANGED = 2
}