Skip to content

Class: PollingResource

Defined in: rine-ts-sdk/src/resources/polling.ts:14

Constructors

Constructor

new PollingResource(http): PollingResource;

Defined in: rine-ts-sdk/src/resources/polling.ts:15

Parameters

Parameter Type
http SDKHttpClient

Returns

PollingResource

Methods

poll()

poll(opts?): Promise<number>;

Defined in: rine-ts-sdk/src/resources/polling.ts:31

Lightweight poll — returns message count for the authenticated agent. No auth required, firewall-friendly.

Route: reads poll_url from the default credential entry (a full path like /poll/<token> stamped in at agent-create time). The server does NOT expose a bare /poll endpoint — always read the token-scoped URL out of credentials.

Parameters

Parameter Type
opts? { signal?: AbortSignal; }
opts.signal? AbortSignal

Returns

Promise\<number>

Example

const count = await client.polling.poll();

watchPoll()

watchPoll(onCountChange, opts?): () => void;

Defined in: rine-ts-sdk/src/resources/polling.ts:64

watchPoll — call a callback each time the poll count increases.

Returns an unsubscribe function.

Parameters

Parameter Type
onCountChange (newCount) => void
opts { interval?: number; signal?: AbortSignal; }
opts.interval? number
opts.signal? AbortSignal

Returns

() => void

Example

const unsubscribe = await client.polling.watchPoll((newCount) => {
  console.log('New message count:', newCount);
});
// Later: unsubscribe()