callstack / react-native-opentok

React Native OpenTok
202 stars 79 forks source link

Signal is not sent #124

Open abdul-elah-js opened 5 years ago

abdul-elah-js commented 5 years ago

I want to send a signal from a connected user and i keep getting 'signal was not sent' error which is driving me crazy, i couldn't even find a solution on the web i've been googling around for hours,

in my case i want to mimic a call so the first user presses a call button which notifies the other user about a phone call, and there i connect to a session and try to signal the first one BUT IT"S NOT WORKING,

here is what i've tried

  componentDidMount = async () => {

    await this.initiate_opentok();

  }

  initiate_opentok = async () => {

    try {

      await OpenTok.connect(this.state.appointment.call_session, this.state.appointment.call_token)

      OpenTok.on(OpenTok.events.ON_SIGNAL_RECEIVED, e => {

        if (e.type == 'answered') this.connect();

        if (e.type == 'rejected') this.disconnect();

      })

    } catch (e) {

      console.warn(e);

    }

  }

  answer = async () => {

    try {

      await OpenTok.sendSignal(this.state.appointment.call_session, 'answered')

    } catch (e) {

      console.warn(e);

    }

  }

what am i doing wrong here ???

help is so appreciated .. Thanks in advance