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

Triggering lifecycle events with CLI and browser extension does not match casing #145

Open mkatenolan opened 1 year ago

mkatenolan commented 1 year ago

I have been trying to use the CLI and browser extension to trigger lifecycle events in an app with listeners set up using Lifecycle.listen as described in SDK docs.

I was making use of the example events in the CLI folder and kept getting the NO-EVENT-HANDLER-REGISTERED error code even though the server was registering listeners with messages like: Registered event listener mapping: 12345:lifecycle.onbackground

If I change the example event method (eg. here) from camelcase to lowercase, the event get triggered correctly. Eg.

{
  "method": "lifecycle.onForeground", // Does NOT trigger event
  "result": {
    "state": "foreground",
    "previous": "background"
  }
}
{
  "method": "lifecycle.onforeground", // Correctly triggers event
  "result": {
    "state": "foreground",
    "previous": "background"
  }
}

Similarly in the browser extension: eg.

async function sendFireboltLifecycleEvent_Inactive(cb) {
  return await _sendFireboltLifecycleEvent('lifecycle.onInactive', { state: 'inactive' }, cb); // Does NOT trigger event
}
async function sendFireboltLifecycleEvent_Inactive(cb) {
  return await _sendFireboltLifecycleEvent('lifecycle.oninactive', { state: 'inactive' }, cb); // Correctly triggers event
}

It seems that either the examples are incorrect or the server is not parsing the events correctly. It would be ideal if we could use the examples out the box rather than having to update them.

kschrief commented 1 year ago

Hi Martha.

I did an investigation. The bug is valid and the PR properly addresses the issue. Thanks for bringing this up! I'm going to approve the PR but we won't be able to merge it in unless you sign the Contributor Agreement. Once that's done everything else should be good to go.