Table of Contents

Notifications

Since version 7.8.7 primitives can subscribe to notifications such that group messages, system alerts, region messages, and so on, can be sent to an URL via HTTP POST. This is done by setting the notifications tag to true in the permissions section of the configuration file Corrade.ini, as well as enabling the required notifications for each group individually by changing the notifications section for each group.

Three-Way Handshake

Since Corrade does not have an interface and the goal is to control Corrade entirely from LSL or HTTP, every notification that you can answer to, has a workflow resembling a three-way handshake. In order to click a button on a dialog, accept a friendship offer, accepting permissions to animate, etc… You will need to always follow the same steps:

  1. Install a notification using the notify command.
    • Corrade will now relay the notification to your script.
  2. When the notification triggers, interpret the output of the notification.
  3. Finally, use the corresponding reply to answer the request.

Example

For example, if you wanted to relay all the chat from a group to the current primitive, you would run the command:

        llInstantMessage(CORRADE, wasKeyValueEncode(
            [
                "command", "notify",
                "group", GROUP,
                "password", PASSWORD,
                "action", "set",
                "type", "group",
                // all group chat will be sent to this URL
                "URL", wasURLEscape(URL)
        ]));

such that all the chat in the group will be relayed to the specified URL. If URL is an in-world URL obtained through llRequestURL, then the primitive that has that URL can process the group messages:

    http_request(key id, string method, string body) {
        llHTTPResponse(id, 200, "Ok");
 
        if(wasKeyValueGet("type", wasURLUnescape(body)) == "group") {
            llOwnerSay("Group message: " + wasKeyValueGet("message", wasURLUnescape(body)));
        }
    }

Or, you could chose to capture both group and alert messages, by issuing:

        llInstantMessage(CORRADE, wasKeyValueEncode(
            [
                "command", "notify",
                "group", GROUP,
                "password", PASSWORD,
                "action", "set",
                // subscribe to group messages and system alerts
                "type", wasListToCSV(["group", "alerts"]),
                // all group chat will be sent to this URL
                "URL", wasURLEscape(URL)
        ]));

then in the primitive that has the URL, you would process the messages:

    http_request(key id, string method, string body) {
        llHTTPResponse(id, 200, "Ok");
 
        string type = wasKeyValueGet("type", wasURLUnescape(body));
        if(type == "alert") {
            llOwnerSay("restart message: " + wasKeyValueGet("message", wasURLUnescape(body)));
        }
    }

which will print out region restart messages.

You can also get the notifications that the script is currently subscribed to:

        llInstantMessage(CORRADE, wasKeyValueEncode(
            [
                "command", "notify",
                "group", GROUP,
                "password", PASSWORD,
                "action", "list",
                "callback", wasURLEscape(URL)
        ]));

which will send the result to the callback URL:

    http_request(key id, string method, string body) {
        llHTTPResponse(id, 200, "Ok");
 
        list notifications = wasCSVToList(wasKeyValueGet("notifications", wasURLUnescape(body)));
        llOwnerSay("Currently subscribed to notifications: " + wasListToCSV(notifications));
    }

Note that notifications are not persistent across Corrade restarts and that it is ideal to always check whether the URL is subscribed to notifications and to set them in case Corrade restarts.

For a full list of notifications, please see the API page on notifications.

Index