diff --git a/src/api.ts b/src/api.ts index 6aaa310..ec63fe7 100644 --- a/src/api.ts +++ b/src/api.ts @@ -223,42 +223,10 @@ export class RondevuAPI { } /** - * Get all answered offers (efficient batch polling for offerer) - */ - async getAnsweredOffers(since?: number): Promise<{ - offers: Array<{ - offerId: string; - serviceId?: string; - answererId: string; - sdp: string; - answeredAt: number; - }>; - }> { - const auth = await this.generateAuthParams('getAnsweredOffers', since?.toString() || ''); - const url = new URL(`${this.baseUrl}/offers/answered`); - - if (since) { - url.searchParams.set('since', since.toString()); - } - url.searchParams.set('username', auth.username); - url.searchParams.set('signature', auth.signature); - url.searchParams.set('message', auth.message); - - const response = await fetch(url.toString()) - - if (!response.ok) { - const error = await response.json().catch(() => ({ error: 'Unknown error' })) - throw new Error(`Failed to get answered offers: ${error.error || response.statusText}`) - } - - return await response.json() - } - - /** - * Combined efficient polling for answers and ICE candidates + * Combined polling for answers and ICE candidates * Returns all answered offers and ICE candidates since timestamp */ - async pollOffers(since?: number): Promise<{ + async poll(since?: number): Promise<{ answers: Array<{ offerId: string; serviceId?: string; @@ -273,8 +241,8 @@ export class RondevuAPI { createdAt: number; }>>; }> { - const auth = await this.generateAuthParams('pollOffers', since?.toString() || ''); - const url = new URL(`${this.baseUrl}/offers/poll`); + const auth = await this.generateAuthParams('poll', since?.toString() || ''); + const url = new URL(`${this.baseUrl}/poll`); if (since) { url.searchParams.set('since', since.toString()); @@ -287,7 +255,7 @@ export class RondevuAPI { if (!response.ok) { const error = await response.json().catch(() => ({ error: 'Unknown error' })) - throw new Error(`Failed to poll offers: ${error.error || response.statusText}`) + throw new Error(`Failed to poll: ${error.error || response.statusText}`) } return await response.json() diff --git a/src/rondevu-signaler.ts b/src/rondevu-signaler.ts index 04f8a53..f0db5f7 100644 --- a/src/rondevu-signaler.ts +++ b/src/rondevu-signaler.ts @@ -245,7 +245,7 @@ export class RondevuSignaler implements Signaler { /** * Start combined polling for answers and ICE candidates (offerer side) - * Uses pollOffers() for efficient batch polling + * Uses poll() for efficient batch polling */ private startPolling(): void { if (this.pollingTimeout || !this.isOfferer) { @@ -258,7 +258,7 @@ export class RondevuSignaler implements Signaler { const poll = async () => { try { - const result = await this.rondevu.pollOffers(this.lastPollTimestamp) + const result = await this.rondevu.poll(this.lastPollTimestamp) let foundActivity = false diff --git a/src/rondevu.ts b/src/rondevu.ts index 700267b..3d35d86 100644 --- a/src/rondevu.ts +++ b/src/rondevu.ts @@ -297,26 +297,10 @@ export class Rondevu { } /** - * Get all answered offers (efficient batch polling for offerer) - * Returns all offers that have been answered since the given timestamp - */ - async getAnsweredOffers(since?: number): Promise<{ - offers: Array<{ - offerId: string - serviceId?: string - answererId: string - sdp: string - answeredAt: number - }> - }> { - return await this.getAPI().getAnsweredOffers(since) - } - - /** - * Combined efficient polling for answers and ICE candidates + * Combined polling for answers and ICE candidates * Returns all answered offers and ICE candidates for all peer's offers since timestamp */ - async pollOffers(since?: number): Promise<{ + async poll(since?: number): Promise<{ answers: Array<{ offerId: string serviceId?: string @@ -331,7 +315,7 @@ export class Rondevu { createdAt: number }>> }> { - return await this.getAPI().pollOffers(since) + return await this.getAPI().poll(since) } /**