opentok / cordova-plugin-opentok

Cordova Plugin for OpenTok - add webrtc video to your iOS or Android App
MIT License
30 stars 80 forks source link

session.signal data object is sent as string #152

Open Shtibel opened 5 years ago

Shtibel commented 5 years ago

Hi there, We are working with signaling on our project we have a website and an Ionic application. On the website we work with the opentok CDN: <script src="https://static.opentok.com/v2/js/opentok.min.js"></script>

On the Ionic application we work with opentok plugin: <script src="opentok.js"></script>

When we send a signal object with the CDN we get back: data as an object. When we send a signal object with the cordova plugin we get back: data as a string. So in the app we must do: JSON.parse(event.data);.

So this is our code in the Ionic application: Sending signal:

this.session.signal({
   data:{
      type:'publishVideo' , 
      value: this.isUserVideo
   }
});

Getting the signal:

this.session.on({
   signal: (event) => {
      let data = JSON.parse(event.data);
      let type = data.type;
      let value = data.value;
      --- Doing some functionality ---
   }
});

So the question is why is this not getting back as an object just like in the CDN version? Why are things (like signaling) not working the same in both?

Thank you.

msach22 commented 5 years ago

@Shtibel The Cordova plugin only supports sending the signal as the following:


session.signal({
  data: '', // string
  type: '', // string
  to: '', //string
});