ResourceRequestObserver

Description

Supported Script Types: Interface Scripts • Client Entity Scripts • Avatar Scripts

The ResourceRequestObserver API provides notifications when an observable resource request is made.

Signals

Name Summary
resourceRequestEvent

Triggered when an observable resource request is made.

Type Definitions

ResourceRequest
Type: object

Information about a resource request.

Properties

Name Type Summary
url string

The URL of the resource request.

callerId number

An ID identifying the request.

extra string

Extra information about the request.

Signal Details

resourceRequestEvent( request )
Returns: Signal

Triggered when an observable resource request is made.

Parameters

Name Type Description
request ResourceRequestObserver.ResourceRequest

Information about the resource request.

Example

Report when a particular Clipboard.importEntities() resource request is made.

ResourceRequestObserver.resourceRequestEvent.connect(function (request) {
    if (request.callerId === 100) {
        print("Resource request: " + JSON.stringify(request));
    }
});

function importEntities() {
    var filename = Window.browse("Import entities to clipboard", "", "*.json");
    if (filename) {
        Clipboard.importEntities(filename, true, 100);
        pastedEntities = Clipboard.pasteEntities(Vec3.sum(MyAvatar.position,
            Vec3.multiplyQbyV(MyAvatar.orientation, { x: 0, y: 0, z: -3 })));
        print("Entities pasted: " + JSON.stringify(pastedEntities));
    }
}

Script.setTimeout(importEntities, 2000);