Scope JavaScript API

This document describes the JavaScript functions provided to special debugger windows in Opera. The functions provide a means to communicate with scope.

A very basic implementation can be found in modules/scope/clients/scope-js-client/scope-js-api.html. A real world example is the Opera Dragonfly application.

This API is only available to windows with a Window_Type value WIN_TYPE_DEVTOOLS.

Functions provided by Opera

The following functions exists on the opera object:

scopeAddClient(host_connected, receive_data, host_quit, port)
scopeEnableService(service)
scopeTransmit(service, data)

The parameters are as follows:

host_connected
This is a callback function called when a host connects.
It is called immediately if a host is already connected.
It must have the signature host_connected(services) where services is a comma-separated list of the services offered by the host.
receive_data
This is a callback function called when data is received from the host.
It must have the signature receive(service, data) where service is the sending service and data is the data sent.
host_quit
This is a callback function called when the host quits.
It must have the signature host_quit().
service
This is a string containing the service name, e.g. "console-logger" to enable or transmit data to.
data
This is a string containing containing the data to be sent, defined by the according service's protocol document.