观影室起步
This commit is contained in:
@@ -0,0 +1,132 @@
|
||||
// 观影室相关类型定义
|
||||
|
||||
export interface Room {
|
||||
id: string;
|
||||
name: string;
|
||||
description: string;
|
||||
password?: string;
|
||||
isPublic: boolean;
|
||||
ownerId: string;
|
||||
ownerName: string;
|
||||
memberCount: number;
|
||||
currentState: PlayState | LiveState | null;
|
||||
createdAt: number;
|
||||
lastOwnerHeartbeat: number;
|
||||
}
|
||||
|
||||
export interface Member {
|
||||
id: string;
|
||||
name: string;
|
||||
isOwner: boolean;
|
||||
lastHeartbeat: number;
|
||||
}
|
||||
|
||||
export interface PlayState {
|
||||
type: 'play';
|
||||
url: string;
|
||||
currentTime: number;
|
||||
isPlaying: boolean;
|
||||
videoId: string;
|
||||
videoName: string;
|
||||
episode?: number;
|
||||
source: string;
|
||||
}
|
||||
|
||||
export interface LiveState {
|
||||
type: 'live';
|
||||
channelId: string;
|
||||
channelName: string;
|
||||
channelUrl: string;
|
||||
}
|
||||
|
||||
export interface ChatMessage {
|
||||
id: string;
|
||||
userId: string;
|
||||
userName: string;
|
||||
content: string;
|
||||
type: 'text' | 'emoji';
|
||||
timestamp: number;
|
||||
}
|
||||
|
||||
export interface RoomMemberInfo {
|
||||
roomId: string;
|
||||
userId: string;
|
||||
userName: string;
|
||||
isOwner: boolean;
|
||||
}
|
||||
|
||||
// Socket.IO 事件类型
|
||||
export interface ServerToClientEvents {
|
||||
'room:created': (room: Room) => void;
|
||||
'room:joined': (data: { room: Room; members: Member[] }) => void;
|
||||
'room:left': () => void;
|
||||
'room:list': (rooms: Room[]) => void;
|
||||
'room:member-joined': (member: Member) => void;
|
||||
'room:member-left': (userId: string) => void;
|
||||
'room:deleted': () => void;
|
||||
'play:update': (state: PlayState) => void;
|
||||
'play:seek': (currentTime: number) => void;
|
||||
'play:play': () => void;
|
||||
'play:pause': () => void;
|
||||
'play:change': (state: PlayState) => void;
|
||||
'live:change': (state: LiveState) => void;
|
||||
'chat:message': (message: ChatMessage) => void;
|
||||
'voice:offer': (data: { userId: string; offer: RTCSessionDescriptionInit }) => void;
|
||||
'voice:answer': (data: { userId: string; answer: RTCSessionDescriptionInit }) => void;
|
||||
'voice:ice': (data: { userId: string; candidate: RTCIceCandidateInit }) => void;
|
||||
'error': (message: string) => void;
|
||||
}
|
||||
|
||||
export interface ClientToServerEvents {
|
||||
'room:create': (data: {
|
||||
name: string;
|
||||
description: string;
|
||||
password?: string;
|
||||
isPublic: boolean;
|
||||
userName: string;
|
||||
}, callback: (response: { success: boolean; room?: Room; error?: string }) => void) => void;
|
||||
|
||||
'room:join': (data: {
|
||||
roomId: string;
|
||||
password?: string;
|
||||
userName: string;
|
||||
}, callback: (response: { success: boolean; room?: Room; members?: Member[]; error?: string }) => void) => void;
|
||||
|
||||
'room:leave': () => void;
|
||||
|
||||
'room:list': (callback: (rooms: Room[]) => void) => void;
|
||||
|
||||
'play:update': (state: PlayState) => void;
|
||||
'play:seek': (currentTime: number) => void;
|
||||
'play:play': () => void;
|
||||
'play:pause': () => void;
|
||||
'play:change': (state: PlayState) => void;
|
||||
|
||||
'live:change': (state: LiveState) => void;
|
||||
|
||||
'chat:message': (data: { content: string; type: 'text' | 'emoji' }) => void;
|
||||
|
||||
'voice:offer': (data: { targetUserId: string; offer: RTCSessionDescriptionInit }) => void;
|
||||
'voice:answer': (data: { targetUserId: string; answer: RTCSessionDescriptionInit }) => void;
|
||||
'voice:ice': (data: { targetUserId: string; candidate: RTCIceCandidateInit }) => void;
|
||||
|
||||
'heartbeat': () => void;
|
||||
}
|
||||
|
||||
// 配置类型
|
||||
export interface WatchRoomConfig {
|
||||
enabled: boolean;
|
||||
serverType: 'internal' | 'external';
|
||||
externalServerUrl?: string;
|
||||
externalServerAuth?: string;
|
||||
}
|
||||
|
||||
// LocalStorage 存储的房间信息
|
||||
export interface StoredRoomInfo {
|
||||
roomId: string;
|
||||
roomName: string;
|
||||
isOwner: boolean;
|
||||
userName: string;
|
||||
password?: string;
|
||||
timestamp: number;
|
||||
}
|
||||
Reference in New Issue
Block a user