import { ServiceDependencies } from "@/services";
import { MatchInfo, MatchRequest } from "@/services/matching";
export interface CallContext {
services: ServiceDependencies;
// Media streams
localStream: MediaStream | null;
remoteStream: MediaStream | null;
// Session info
matchRequest: MatchRequest | null;
sessionInfo: MatchInfo | null;
// Error handling
error: Error | null;
}
export type CallEvent =
// Lifecycle events
| { type: "lifecycle.init" }
| { type: "lifecycle.reset" }
// Media events
| { type: "media.ready"; stream: MediaStream }
| { type: "media.error"; error: Error }
| { type: "media.stream-ended" }
// Signaling events
| { type: "signaling.connected" }
| { type: "signaling.disconnected" }
| { type: "signaling.error"; error: Error }
// User actions
| { type: "user.start-call"; request: MatchRequest }
| { type: "user.next-call"; request: MatchRequest }
| { type: "user.end-call" }
| { type: "user.switch-camera" }
| { type: "user.toggle-audio" }
// Match events
| { type: "match.found"; result: MatchInfo }
| { type: "match.failed" }
| { type: "match.timeout", error: Error }
| { type: "match.error"; error: Error }
// WebRTC connection events
| { type: "connection.ice-candidate"; candidate: RTCIceCandidateInit }
| { type: "connection.ice-connected" }
| { type: "connection.ice-disconnected" }
| { type: "connection.ice-failed" }
| { type: "connection.state-changed"; state: RTCPeerConnectionState }
| { type: "connection.failed"; error: Error }
| { type: "connection.closed" }
// Remote stream events
| { type: "remote.stream-ready"; stream: MediaStream }
| { type: "remote.stream-ended" }