- See also
// 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.