Genvid Forum

Event subscription via Web API


#1

Hey there! So far most things have been pretty smooth sailing with the web SDK - I just have a couple questions that I can’t seem to find the answer to in the documentation:

First, I see the methods exposed via the api to send an event, however on the monitor page, I don’t see any events appearing - perhaps that’s not what that tab is for, though?

Here is the event config file:

    {
      "version": "1.7.0",
      "event": {
        "game": {
          "maps": [
            {
              "id": "cheerTeam",
              "source": "viewers",
              "where": {"key": ["cheerTeam"], "name": "<color>", "type": "string"},
              "key": ["cheerTeam", "<color>"], "value": 1
            },
            {
              "id": "cheerPlayer",
              "source": "viewers",
              "where": {"key": ["cheerPlayer"], "name": "<id>", "type": "string"},
              "key": ["cheerPlayer", "<id>"], "value": 1
            }
          ],
          "reductions": [
            {
              "id": "cheerTeam",
              "where": {"key": ["cheerTeam", "<color>"]},
              "key": ["<color>"],
              "value": ["$count"],
              "period": 250
            },
            {
              "id": "cheerPlayer",
              "where": {"key": ["cheerPlayer", "<id>"]},
              "key": ["<id>"],
              "value": ["$count"],
              "period": 250
            }
          ]
        }
      }
    }

And here is the line where I am calling the event on the client:

client.sendEventObject({ cheerTeam : isBlue?"blue":"gold" })

It looks like the event is being sent to the socket correctly, but it does not show up in the event page, in the event logs, or in the stream data - which brings me to my second item:

I see in the documentation that in order to receive event information, you have to subscribe to that event. I can find the methods for this in the other APIs, however I don’t see one for the web API; Is there a way to subscribe to events via the web API?

Thanks!
Lucas


#2

Thanks Lucas. I confirm your message and we will respond soon.


#3

Hi Lucas,

I have verified with our sample tutorial that the events do appear (as seen in the screenshot below). However, I did notice a lag before events were logged/displayed. I also clicked it repeatedly to ensure I saw results.

Did you click multiple times and wait a few moments before checking again?

Additionally, if you refresh the browser page, the data will be erased. This applies to changing menus in the Cluster-UI.

Could you please try the following steps?

  1. [Start All] jobs
  2. Click Demo link to open viewer/streaming page (in new tab)
  3. Go to back to Cluster-UI, click on Events
  4. Return to the viewer/streaming page, click to trigger events
  5. Go to back to Cluster-UI, verify if the events are listed.

Another step to try: rebuild the “web” job: (which I did after adding your variables for testing)
Example: py tutorial.py build web

The Events console page is meant for reference only to validate the data output is functional, not for long-term tracking (these results are not saved).

Please let me know if this answers your questions.

Cheers,
Sophie


Tutorial Sample Events


#4

Weird! Thank you so much for digging into that!

Alright, something must be janked up on my end, then; I rebuild the web component and it still isn’t showing up - I’ll try running the sample again later today to see if I can replicate the events showing up (or if I’ve messed something up higher up the chain.)

Just to clarify, is that data accessible from the web client (not the monitor) as well? Meaning, can I access the event data with the web API via javascript? - It’s possible that it just gets sent over the stream and since it isn’t posting for me, I’m not seeing it - I just wanted to make sure I wasn’t going to be chasing a solution that didn’t actually tackle the end-goal I had.


#5

Hi Lucas,

The event are filtered because of the map source is set to “viewers” instead of “userinput”.

Unfortunately, I just notice that it’s not documented, so I will open a ticket to change the situation.

Henri


#6

Hey Henri -

Ah! Perfect, yes, those events are now showing up in the events panel after changing the source to “userinput” - that just leaves me with my second question:

I have this information on the events panel -

Now that I have that, how do I pull in that event information via the web client? I’ve tried adding event listeners to the body/Genvid client, and have checked out the onNotificationsReceived() method and the stream data, and I don’t see those events being sent to any of those, so I suspect there is some other endpoint that I can request from/some other web service I can run to get an up-to-date event stream.

Thanks!
Lucas


#7

Hi Lucas,

Unfortunately, there is no endpoint on the web client for these events. However, they are sent to the game. So it’s up to the game to decide what to do with them.

In the sample, the game analyzes the cheer and send feedback to the web client through the game data stream.

The game can also send notifications and annotations.

We explain those streams here: https://www.genvidtech.com/doc/SDK-1.12.0/architecture/streams/streams.html

I also invite you to read about the tutorial game integration.
https://www.genvidtech.com/doc/SDK-1.12.0/samples/tutorial/tutorial_app.html?highlight=tutorial#genvid-integration

Hope that this help.

Henri


#8

Hey Henri -

Cool, that’s what I was wondering - I’ll talk to the team working on the game side to coordinate that, then.

Thanks!
Lucas