import { GNHashtable } from "./../common/GNData"; import { RequestRole } from "./../constant/enumType/RequestRole"; import { RequestType } from "./../constant/enumType/RequestType"; import { Action1 } from "./../common/Action1"; import { OperationRequest } from "./../entity/OperationRequest"; import { OperationResponse } from "./../entity/OperationResponse"; /** * Per-request bookkeeping entry tracked by {@link PeerBase}. * * Lifecycle: * 1. Constructed inside {@link PeerBase.enqueue} when caller code * issues a request. The constructor seeds an absolute timeout * deadline using the SDK-wide * {@link OperationRequest.defaultTimeOut} fallback, plus copies * every per-request override (auth token, secret key, custom tags, * game id) into private fields so the queue can be drained without * another lookup against the shared {@link AuthenticateStatus}. * 2. Pushed into the FIFO queue. While waiting it is only inspected by * `service()` for queue ordering. * 3. Sent via {@link PeerBase.send}, which calls {@link onSend} to * record the wall-clock send time and recompute the timeout * deadline using the request-specific timeout. The entry then moves * into the in-flight map keyed by `requestId` (when a callback is * registered). * 4. Resolved by {@link PeerBase.onResponseHandler}, which calls * {@link onRecv} so {@link getExecuteTimerInMs} can return the * measured round-trip in milliseconds. * * Timeout semantics: `timeout` is an absolute `Date.now()`-style epoch * milliseconds value. The 0.1s timeout sweep inside `service()` checks * every in-flight pending entry against the current time and synthesises * a `ReturnCode.OperationTimeout` response when it has elapsed. */ export declare class OperationPending { private operationRequest; private requestType; private role; private authToken; private secretKey; private gameId; private customTags; private onOperationResponse; private timeout; private firstSend; private secondsSend; /** * Captures every bit of state needed to send and later correlate * the request without revisiting the shared SDK state. * * @param requestType Logical request category. * @param role Permission scope evaluated by the * backend. * @param operationRequest Pre-built request (operation code, * parameters, request id, timeout * override). * @param onOperationResponse Optional callback. `null` makes this * a fire-and-forget entry; the timeout * sweep still fires but nobody is * notified of the timeout response. * @param authToken Auth token to send with this request. * @param secretKey Game-specific shared secret. * @param customTags Routing / telemetry tags merged into * the outbound payload. * @param gameId Game identifier for the `Game-Id` * header. */ constructor(requestType: RequestType, role: RequestRole, operationRequest: OperationRequest, onOperationResponse: Action1, authToken: string, secretKey: string, customTags: GNHashtable, gameId: string); /** * Returns the logical request category recorded at enqueue time. */ getRequestType(): RequestType; /** * Returns the permission role recorded at enqueue time. */ getRole(): RequestRole; /** * Returns the auth token captured at enqueue time. * * The token is copied verbatim into the entry — later mutations * to {@link AuthenticateStatus} do not affect already-queued * pending operations. */ getAuthToken(): string; /** * Returns the secret key captured at enqueue time. */ getSecretKey(): string; /** * Returns the game id captured at enqueue time. */ getGameId(): string; /** * Returns the custom tags captured at enqueue time, or `null` when * none were supplied. */ getCustomTags(): GNHashtable; /** * Marks the operation as just sent and recomputes the absolute * timeout deadline using the request-specific timeout. * * Called from {@link PeerBase.send} immediately before the actual * transport-specific dispatch. The deadline value is later read by * {@link isTimeout} during the periodic timeout sweep. */ onSend(): void; /** * Marks the operation as resolved so the round-trip duration can * be measured. * * Called from {@link PeerBase.onResponseHandler} when a matching * response arrives. The captured timestamp is paired with * {@link firstSend} by {@link getExecuteTimerInMs}. */ onRecv(): void; /** * Returns the round-trip duration in milliseconds. * * Defined as `secondsSend - firstSend`. The peer feeds half of * this value into {@link PeerBase.addPing} as the per-request * one-way latency measurement. * * @returns Duration in milliseconds, or a negative / zero value * when {@link onRecv} has not fired yet. */ getExecuteTimerInMs(): number; /** * Returns whether the absolute timeout deadline has elapsed. * * The peer's `service()` sweeps with this method every 0.1s and * synthesises a `ReturnCode.OperationTimeout` response when it * returns `true`. */ isTimeout(): boolean; /** * Returns the underlying {@link OperationRequest} captured at * construction time. */ getOperationRequest(): OperationRequest; /** * Returns the response callback captured at construction time, or * `null` for a fire-and-forget entry. */ getCallback(): Action1; }