accelerator-core-js icon indicating copy to clipboard operation
accelerator-core-js copied to clipboard

Unnecessary JSON.stringify when sending signals?

Open caffodian opened this issue 4 years ago • 1 comments

New issue checklist

  • [x] I have read all of the README
  • [x] I have searched existing issues and this is not a duplicate.

General information

  • Library version(s): 2.0.15
  • iOS/Android/Browser version(s): any
  • Devices/Simulators/Machine affected: all
  • Reproducible in the demo project? (Yes/No): any
  • Related issues:

Bug report

the signal sender always stringifys the signal data, but the core library and servers are able to take Objects as is. This means that for signals send using the accelerator, an extra parse is needed that isn't necessarily when sending identical signals from non-accelerator client, or from the server.

https://github.com/opentok/accelerator-core-js/blob/master/src/core.js#L590

Expected behavior

  • data is passed through as is

Actual behavior

  • data is passed through as a string

Steps to reproduce

  • send a signal with accelerator's signal function, pass an object as data
  • receive that signal - you will need to JSON.parse the data field

Question or Feature Request

Is this by design? It doesn't appear to be a documented difference. feels like it shouldn't be happening, but maybe users of this library are used to this by now?

caffodian avatar May 18 '20 22:05 caffodian

@caffodian this makes a lot of sense. Thanks for the input. I'm working on this change now, but it may be a bit before it's in the wild. I imagine this will require a major version change as it could potentially break dependent apps.

michaeljolley avatar Jul 19 '20 05:07 michaeljolley