rdkcentral / mock-firebolt

An advanced, controllable mock Firebolt OS implementation, which can also act as a reverse proxy to a real Firebolt OS running on a real device
Apache License 2.0
4 stars 21 forks source link

Figuring out how to trigger an event with discovery.launch to the homescreen #107

Open nicolasperedoesquivel opened 1 year ago

nicolasperedoesquivel commented 1 year ago

Hey all,

I'm trying to trigger an event as follows:

{ "jsonrpc": "2.0", "method": "discovery.launch", "params": { "appId": "app_name", "intent": { "action": "home", "context": { "source": "device" } } } }

And when I call it in the terminal as a cli command: node cli.mjs --event ../examples/discovery-onNavigateToHome.even.json I'm getting this response

You may want to create a .mf.config.json file for personal use. UserId: 12345 Sending event based on file ../examples/discovery-onNavigateToHome.even.json... { "status": "ERROR", "errorCode": "NO-EVENT-HANDLER-REGISTERED", "message": "Could not send discovery.launch event because no listener is active" }

Im listening to that event in my project as Discovery.launch(Discovery.events.launch, (intent = {}) => { console.log('intent', intent) })

I'm blocked on this since last week and I ran out of ideas. Can someone help me or give me a workaround of how to trigger a Discovery Launch event so I can open my app with deep link ?

michaelcfine commented 1 year ago

Hi there. Hmm... The NO-EVENT-HANDLER-REGISTERED error is returned when Mock Firebolt doesn't "know about" a corresponding event listener. Basically, that code prevents Mock Firebolt from sending the event to the Firebolt SDK running in a client app if there isn't an event listener setup in the app. It looks like you're trying to create a listener, but one thing I notice is that the first parameter to Discovery.launch is supposed to be a string (appId; see https://developer.comcast.com/firebolt-apis/core-sdk/v0.9.0/discovery#launch). More, I'm not sure you can catch the launch event; I don't see it as an actual event. One thing I might recommend is to try some other event (maybe closed captions settings changed) to confirm you've got the pattern down.

nicolasperedoesquivel commented 1 year ago

Hey, thanks for the response. I've also been testing the navigateTo event, and yes now I've noticed that Discovery module only have two events and launch isn't one of them. I trigger the event listener for navigateTo as I send this in the terminal: node cli.mjs --event ../examples/discovery-onNavigateToDetail.event.json

And the event listener is implemented this way:

Discovery.listen(Discovery.events.navigateTo, (intent = {}) => {
        console.log('intent in navigateTo listener', intent)
      })

This works but I have issues about the discovery launch as I don't know how to implement it through mock-firebolt. I want to do a deeplink from outside the app and open an entity or a screen inside my app. Btw, the code that I've posted in the beginning was awful. This is the current code that I have in my index.

Discovery.launch('app_id', {
        action: 'entity',
        context: { source: 'device' },
        data: { entityId: 'entity_id' },
      }).then((success) => {
        console.log(success)
      })

Best regards,