opentok / opentok-react-native

OpenTok React Native - a library for OpenTok iOS and Android SDKs
https://tokbox.com/
MIT License
210 stars 155 forks source link

[bug-report] subscriber `connected` eventHandler is called with different arguments for android and iOS #360

Open willhoney7 opened 4 years ago

willhoney7 commented 4 years ago

Bug Report

Current behavior

The connected eventHandler of the OTSubscriber component is called with different arguments based on the platform.

Steps to reproduce Add a connected eventHandler to the OTSubscriber component and look at the event arguments on android and on iOS.

Example Project I'm hoping this isn't necessary for this specific case. If necessary, I can provide one.

What is the current bug behavior? Android and iOS have different event result shapes.

What is the expected correct behavior? Android and iOS should have the same event result shape.

Relevant logs and/or screenshots

<OTSubscriber
  eventHandlers={{
    connected(event) {
      console.log(event);
      // iOS result
      {
        connection: { ... },
        connectionId: "XXXXX",
        creationTime: "2019-10-10 18:49:31",
        hasAudio: false,
        hasVideo: true,
        height: 480,
        name: "",
        sessionId: "XXXXX",
        streamId: "XXXXX",
        videoType: "camera",
        width: 640
      }

      // android result
      {
        stream: {
          connection: { ... },
          connectionId: "XXXXX",
          creationTime: "Thu Oct 10 12:49:31 MDT 2019",
          hasAudio: false,
          hasVideo: true,
          height: 480,
          name: "",
          sessionId: "XXXXX",
          streamId: "XXXXX",
          videoType: "camera",
          width: 640
        }
      }
  }
/>

Other notes It's entirely possible the other events have the same issue. We're only looking at the connected event in our application.

pietgk commented 12 months ago

any status update regarding this?

jeffswartz commented 1 month ago

How do you propose we fix this in the SDK without breaking backwards compatibility? Some developers may have added code to process the events differently based on the client platform (Platform.OS). And if we change the TypeScript type for the event from Callback<any> (which is what it is now) to something more specific, we could also break existing code.

Perhaps we should just leave the types set to Callback<any>, and add redundant properties in the event data:

{
  connection: { ... },
  connectionId: "XXXXX",
  // ...
  stream: {
    connection: { ... },
    connectionId: "XXXXX",
    // ...
  }
}