Ramble-FE / services / matching / matching.types.ts
matching.types.ts
Raw
import { Gender, Language, Region } from "@/types/preferences";
import { SignalingRole } from "../webrtc";

export const MatchStatus = {
    SUCCESS: "SUCCESS",
    WAITING: "WAITING",
    FAILED: "FAILED",
} as const;

export type MatchStatus = (typeof MatchStatus)[keyof typeof MatchStatus];

export interface MatchRequest {
    region: Region;
    gender: Gender;
    language: Language;
}

export interface MatchResponse {
    status: MatchStatus;
    message: string;
    data?: MatchInfo;
}

export interface MatchInfo {
    sessionId: string;
    role: SignalingRole | null;
    otherUserId: string;
}

// 서버 응답 변경 전 임시. 서버 변경 전까지 유지
export interface MatchResponseTemp {
    status: MatchStatus;
    role: SignalingRole | null;
    partnerInfo: string | null;
}

export interface MatchingEventMap {
    "matching:found": (MatchResult: MatchInfo) => void;
    "matching:failed": (error: Error | string) => void;
    "matching:timeout": (error: Error | string) => void;
    "matching:error": (error: Error) => void;
}