cohtml::IAsyncResourceHandler

Class that will handle all asynchronous resource requests.

#include <ResourceHandler.h>

Public Functions

Name
virtual~IAsyncResourceHandler()
virtual voidOnResourceRequest(const cohtml::IAsyncResourceRequest * request, cohtml::IAsyncResourceResponse * response) =0
Called when Cohtml needs a resource.
virtual voidOnResourceStreamRequest(const cohtml::IAsyncResourceRequest * request, cohtml::IAsyncResourceStreamResponse * response) =0
Called when Cohtml needs a resource stream.
virtual voidOnAbortResourceRequest(unsigned id) =0
Called when a requested resource is not needed anymore.

Protected Functions

Name
IAsyncResourceHandler()

Public Functions Documentation

function ~IAsyncResourceHandler

virtual ~IAsyncResourceHandler()

function OnResourceRequest

virtual void OnResourceRequest(
    const cohtml::IAsyncResourceRequest * request,
    cohtml::IAsyncResourceResponse * response
) =0

Called when Cohtml needs a resource.

Parameters:

  • request object describing the resource requested
  • response response object for result of loading the request

Note: Can be called on any thread.

function OnResourceStreamRequest

virtual void OnResourceStreamRequest(
    const cohtml::IAsyncResourceRequest * request,
    cohtml::IAsyncResourceStreamResponse * response
) =0

Called when Cohtml needs a resource stream.

Parameters:

  • request object describing the resource requested
  • response response object for result of loading the request

Note: Can be called on any thread.

function OnAbortResourceRequest

virtual void OnAbortResourceRequest(
    unsigned id
) =0

Called when a requested resource is not needed anymore.

Parameters:

  • id the id associated with the resource request

Note:

  • Can be called on any thread. Can be received after the client responded and called IAsyncResourceResponse::Finish, in that case just ignore the notification.
  • This method will only be invoked when the requests are in synchronous mode which is achieved by setting SystemSettings::AsynchronousResourceRequestCalls option to false. Aborting resources in asynchronous request mode is not possible due to timing issues between the callbacks of the resource handler. The client can still respond on any thread, but has to manage possible race conditions between the responses and the abort notifications.
  • The client is STILL REQUIRED to call IAsyncResourceResponse::Finish on the resource response object with the associated request.

Protected Functions Documentation

function IAsyncResourceHandler

IAsyncResourceHandler()