StreamConnection

AMD: require(["esri/layers/support/StreamConnection"], (StreamConnection) => { /* code goes here */ });
ESM: import StreamConnection from "@arcgis/core/layers/support/StreamConnection";
Object: esri/layers/support/StreamConnection
Since: ArcGIS API for JavaScript 4.25

A web socket connection to a stream service. The connection to the stream service can be established by calling StreamLayer's connect() method.

See also
Example
// get layer's connection configurations
const parameters = layer.createConnectionParameters();

// set the spatial reference of the service geometries
parameters.spatialReference = new SpatialReference({
  wkid: 2154
});

const connection = await layer.connect(parameters);

// listen to date-received event once the connection is established
// create a graphic from the JSON object returned and add them to view
connection.on("data-received", (feature) => {
  const graphic = Graphic.fromJSON(feature);
  graphic.symbol = myPointSymbol;
  view.graphics.push(graphic);
});

// close the connection when it is not needed anymore
connection.destroy();

Property Overview

Name Type Summary Object
Error

The error that explains an unsuccessful attempt to connect to the stream service or an unexpected disconnection from the stream service.

more details
StreamConnection
String

The status of the Web Socket connection with the stream service.

more details
StreamConnection

Property Details

connectionError Errorreadonly

The error that explains an unsuccessful attempt to connect to the stream service or an unexpected disconnection from the stream service.

connectionStatus Stringreadonly

The status of the Web Socket connection with the stream service. This property can be watched to see if the connection is lost unexpectedly.

Possible Values:"connected"|"disconnected"

Method Overview

Name Return Type Summary Object

Destroys the existing connection instance to the stream service.

more details
StreamConnection

Method Details

destroy()

Destroys the existing connection instance to the stream service.

Event Overview

Name Type Summary Object
{attributes: Object,geometry: Object}

Fires when the stream connection receives data.

more details
StreamConnection

Event Details

data-received

Fires when the stream connection receives data. The event object contains the message properties received from the stream service.

Properties
attributes Object

Name-value pairs of fields and field values associated with the received data.

geometry Object

A location of the received data containing x, y coordinates for points, paths for lines and rings for polygons, and the spatial reference wkid.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.