Select to view content in your preferred language

First calls to sendMessageToClient not used applied

1255
2
Jump to solution
04-09-2024 05:57 AM
snlasystem
Occasional Contributor

Hi,

I'm experiencing some problems with the ArcGIS JS SDK's StreamLayer.

It seems that an initial call to sendMessageToClient() is not being considered.

If I change the timeout in https://codepen.io/Kiachma/pen/ZEqgOVQ?editors=1111 to something less than 2000 as it is now, then the example doesn't work. Is this a bug or do I need to add some checks before I call sendMessageToClient? I assumed that I could call sendMessageToClient without a timeout.

The example is based on https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-StreamLayer.html#clientsid...

0 Kudos
1 Solution

Accepted Solutions
UndralBatsukh
Esri Regular Contributor

Hi there, 

We addressed this behavior and now you do not need to wait for the layerView.updating becomes false for the first time. You can test the new behavior against our next version

Here is a codepen showing the fix: https://codepen.io/U_B_U/pen/NWmMRZa?editors=1001

View solution in original post

0 Kudos
2 Replies
UndralBatsukh
Esri Regular Contributor

Hi there, 

So I looked at the behavior more.  We will update the sample.

In any case, the first call to sendMessageToClient() should be when the StreamLayerView is fully loaded and ready. I updated your codepen to show the correct workflow: https://codepen.io/U_B_U/pen/NWmMRZa?editors=1001 the main change being what is shown below.

view.whenLayerView(layer).then( async (layerView) =>{
  await reactiveUtils.whenOnce(() => !layerView.updating);
  layerView.on("message-received", (event) =>{
    console.log("message-received event", event);
  });
  layer.sendMessageToClient({YOUR MESSAGE});
});

 

0 Kudos
UndralBatsukh
Esri Regular Contributor

Hi there, 

We addressed this behavior and now you do not need to wait for the layerView.updating becomes false for the first time. You can test the new behavior against our next version

Here is a codepen showing the fix: https://codepen.io/U_B_U/pen/NWmMRZa?editors=1001

0 Kudos