TileRequestChannel Class

A channel over which requests for tile content can be made. The channel may request content over HTTP, calls to the backend via IPC or RPC, or any other method like generating the content on the frontend. The channel consists of a queue of pending requests and a set of "active" requests (dispatched and awaiting a response). Incoming requests are placed onto the queue. Requests are popped of the queue in order of priority and dispatched, until the maximum number of simultaneously-active requests is reached. The maximum number of active requests depends on the transport mechanism. For HTTP 1.1, browsers impose a limit of 6 simultaneous connections to a given domain, so ideally each unique domain will use its own unique channel with a limit of 6 active requests. Even for requests satisfied entirely by the frontend, imposing a limit is important for throttling the amount of work done at one time, especially because as the user navigates the view, tiles that were previously requested may no longer be of interest and we shouldn't waste resources producing their content. A channel must be registered with TileRequestChannels and must have a unique name among all registered channels.

@see - getForHttp to obtain (and register if not already registered) an HTTP-based channel.

  • channels for the channels configured for use with the iTwin.js display system.
  • channel to specify the channel to be used to request a given tile's content.

Methods

Name Description
constructor(name: string, concurrency: number): TileRequestChannel Create a new channel.  
onActiveRequestCanceled(_request: TileRequest): void Invoked when a request that was previously dispatched is canceled before a response is received.  
onIModelClosed(_iModel: IModelConnection): void Invoked when an iModel is closed, to clean up any state associated with that iModel.  
onNoContent(_request: TileRequest): boolean Invoked when requestContent returns undefined.  
processCancellations(): void Invoked to do any additional work to cancel tiles accumulated by onActiveRequestCanceled.  
requestContent(tile: Tile, isCanceled: () => boolean): Promise<TileRequest.Response> Request content for the specified tile.  
resetStatistics(): void Reset all of this channel's statistics to zero.  

Properties

Name Type Description
_statistics Protected TileRequestChannelStatistics    
concurrency Accessor number The maximum number of active requests.  
name Readonly string The channel's name.  
numActive Accessor ReadOnly number The number of requests that have been dispatched and are awaiting a response.  
numPending Accessor ReadOnly number The number of requests that have been enqueued for later dispatch.  
size Accessor ReadOnly number The total number of requests in this channel, whether dispatched or enqueued.  
statistics Accessor ReadOnly Readonly<TileRequestChannelStatistics> Statistics intended primarily for debugging.  

Defined in

Last Updated: 14 November, 2024