Optional
protocols: string | string[]Static
CLOSEStatic
CONNECTEDStatic
DEVICES_Static
DISCONNECTEDStatic
GETStatic
GET_Static
GET_Static
IDStatic
PUBLISHStatic
SEARCHStatic
SEARCH_Static
SERVICE_Static
SUBSCRIBEClose multiple subscriptions in one close
call. The subscription
identifier return in the subscribe
call along with the close function
can be passed in here to close the subscription together with others.
const query = [{
dataset: {
type: 'app',
name: 'analytics'
},
paths: [{
path_elements: ['events', 'activeEvents'],
}],
}];
const handleResponse = (err, res) => {...};
// Send the request
const subscriptionCloseFn = connector.subscribe(query, handleResponse);
// Close the subscription via `closeSubscriptions`
const closeSubscriptions([subscriptionCloseFn.identifier]);
Subscribes a callback to connection events.
The callback can receive either Wrpc.CONNECTED or
Wrpc.DISCONNECTED`.
Subscribes a callback to connection events.
The callback can receive either Wrpc.CONNECTED or
Wrpc.DISCONNECTED`.
Sends the command along with the params to the API, if the WebSocket is connected. The response is received via the provided callback function.
Returns all notifications that match the given Query and Options, in addition to subscribing to updates. This will return notifications as new updates to the data requested come in.
A getAndSubscribe
is done in such a way that no notifications are lost.
Before doing a get
, a subscribe
is initiated and we wait for an active
status message to be returned before initiating a get
. This means no notifications
are missed, but there is a chance of duplicate notifications.
const query = [{
dataset: {
type: 'app',
name: 'analytics'
},
paths: [{
path_elements: ['events', 'activeEvents'],
}],
}];
const options = {
start: 1504113817725,
end: 1504113917725,
};
const handleResponse = (err, res) => {...};
// open the stream
const closeSubscription = connector.getAndSubscribe(
query, handleResponse, options);
closeSubscription(); // close the stream when finished
Returns all notifications that match the given query and options.
const query = [{
dataset: {
type: 'app',
name: 'analytics'
},
paths: [{
path_elements: ['events', 'activeEvents'],
}],
}];
const options = {
start: 1504113817725,
end: 1504113917725,
};
const handleResponse = (err, res) => {...};
// Send the request
connector.getWithOptions(query, handleResponse, options);
Writes data in params to the CloudVision API. It receives one message via the provided callback, to indicate whether the write is successful or not.
Sends the command along with the params to the API, which creates a
subscriptions on the server. It receives a stream of messages via the
provided callback, as these messages get produced.
The client can close the stream with returned close function, or use the
attached identifier (closeFunction.identifier
) to close multiple streams
at once via closeStream
.
Creates a subscription to the given query, which will return notifications as they happen. Note that this will not return any historical data. The first update that is sent will be when the state of the data in the query changes.
const query = [{
dataset: {
type: 'app',
name: 'analytics'
},
paths: [{
path_elements: ['events', 'activeEvents'],
}],
}];
const handleResponse = (err, res) => {...};
// Send the request
const subscriptionCloseFn = connector.subscribe(query, handleResponse);
Write data to the CloudVision API server, where the update is a series of notifications of a certain dataset.
The writeSync operation is synchronous.
The Connector uses WebSocket to enable transmission of data over an open connection with the CloudVision API server. It supports subscriptions, which allows clients to receive streaming updates as data changes in real-time.