How to subscribe to session event(data changing) on Glass(UI) side?

Hello,

is it possible to subscribe to session event(data changing) on Glass(UI) side? We need to apply the logics driven by the putting data to the session at the backend side.

For example, Glass captured the photo and put it to the session data. Backend analyses this photo and send back to Glass information about the asset on the photo through the session again. We need to catch the moment when data was added to the session at the backend.

Could you advise?

Thank you,
Michael

Hi Michael!

Session data events should be available in the applicationEvent script handler. Here is an example of the event object that is passed to the script:

{
  "scriptType": "application",
  "entityType": "session",
  "source": "skylight",
  "eventType": "session_data_updated",
  "applicationId": "5fb277fd9cb3c1fef3d8d385",
  "version": 1,
  "sessionId": "f9d8ae2f-5b36-4d49-919e-ce4c6e835dfb",
  "data": {
    "updated": true
  }
}

The data that was changed can be retrieved by setting the session with skylight.session.set and then retrieving the data from skylight.session.data.

Let me know if there’s anything else that may come up!

Cheers,

~Andrew