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.

Hierarchy

  • default
    • default

Constructors

  • Parameters

    • options: ConnectorOptions = ...
    • websocketClass: (new (url: string | URL, protocols?: string | string[]) => WebSocket) = WebSocket
        • new (url: string | URL, protocols?: string | string[]): WebSocket
        • Parameters

          • url: string | URL
          • Optional protocols: string | string[]

          Returns WebSocket

    • parser: typeof Parser = Parser

    Returns default

Properties

isRunning: boolean
CLOSE: "close" = CLOSE
CONNECTED: "connected" = CONNECTED
DEVICES_DATASET_ID: "DEVICES_DATASET_ID" = DEVICES_DATASET_ID
DISCONNECTED: "disconnected" = DISCONNECTED
GET: "get" = GET
GET_AND_SUBSCRIBE: "getAndSubscribe" = GET_AND_SUBSCRIBE
GET_DATASETS: "getDatasets" = GET_DATASETS
ID: "cloudvision-connector" = ID
PUBLISH: "publish" = PUBLISH
SEARCH: "alpha/search" = SEARCH
SEARCH_SUBSCRIBE: "alpha/searchSubscribe" = SEARCH_SUBSCRIBE
SERVICE_REQUEST: "serviceRequest" = SERVICE_REQUEST
SUBSCRIBE: "subscribe" = SUBSCRIBE

Accessors

Methods

  • Closes one single stream.

    Parameters

    • stream: SubscriptionIdentifier
    • callback: NotifCallback

    Returns null | string

  • Closes multiple streams in one close call.

    Parameters

    • streams: SubscriptionIdentifier[]
    • callback: NotifCallback

    Returns null | string

  • Close 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.

    Example


    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]);

    Parameters

    • subscriptions: SubscriptionIdentifier[]
    • callback: NotifCallback

    Returns null | string

  • Subscribes a callback to connection events. The callback can receive either Wrpc.CONNECTED or Wrpc.DISCONNECTED`.

    Parameters

    • callback: ConnectionCallback

    Returns (() => void)

      • (): void
      • Subscribes a callback to connection events. The callback can receive either Wrpc.CONNECTED or Wrpc.DISCONNECTED`.

        Returns void

  • Sends the command along with the params to the API, if the WebSocket is connected. The response is received via the provided callback function.

    Parameters

    • command: GetCommand
    • params: CloudVisionParams
    • callback: NotifCallback

    Returns null | string

  • 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.

    Example


    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

    Parameters

    • query: Query
    • callback: NotifCallback
    • options: Options

    Returns null | SubscriptionIdentifier

  • Returns all notifications that match the given query and options.

    Example


    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);

    Parameters

    • query: "DEVICES_DATASET_ID" | Query
    • callback: NotifCallback
    • options: Options

    Returns null | string

  • 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.

    Parameters

    • params: CloudVisionPublishRequest
    • callback: NotifCallback

    Returns null | string

  • Send a service request command to the CloudVision API

    Parameters

    • request: ServiceRequest
    • callback: NotifCallback

    Returns null | string

  • Parameters

    • request: ServiceRequest
    • callback: NotifCallback

    Returns null | SubscriptionIdentifier

  • Parameters

    • params: CloudVisionParams
    • callback: NotifCallback

    Returns null | string

  • Parameters

    • query: Query
    • callback: NotifCallback
    • options: SearchOptions = ...

    Returns null | SubscriptionIdentifier

  • Parameters

    • query: Query
    • callback: NotifCallback
    • options: Options & SearchOptions

    Returns null | string

  • 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.

    Parameters

    • command: StreamCommand
    • params: CloudVisionParams | ServiceRequest
    • callback: NotifCallback

    Returns null | SubscriptionIdentifier

  • 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.

    Example


    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);

    Parameters

    • query: Query
    • callback: NotifCallback

    Returns null | SubscriptionIdentifier

  • Write data to the CloudVision API server, where the update is a series of notifications of a certain dataset.

    The writeSync operation is synchronous.

    Parameters

    • publishRequest: PublishRequest
    • callback: PublishCallback

    Returns void