refactor: Rename pollOffers to poll and remove getAnsweredOffers

BREAKING CHANGES:
- Renamed pollOffers() to poll() (matches new /poll endpoint)
- Removed getAnsweredOffers() method (use poll() instead)
- Updated endpoint path from /offers/poll to /poll
- Updated auth message format from 'pollOffers' to 'poll'
This commit is contained in:
2025-12-12 19:13:19 +01:00
parent 214f611dc2
commit b5f36d8f77
3 changed files with 10 additions and 58 deletions

View File

@@ -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()

View File

@@ -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

View File

@@ -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)
}
/**