pdcarroll / react-kinesis-webrtc

An experimental library of React hooks for the AWS Kinesis WebRTC JavaScript SDK.
ISC License
13 stars 7 forks source link

new connection state change handler #18

Closed cyuste closed 2 years ago

cyuste commented 2 years ago

Hi again! I've using the library for a couple of projects and works perfectly. I've made some modifications that I'd like to discuss.

function handleConnectionChange() {
      console.log('New connection state: ', peerConnection?.connectionState)
      if (peerConnection?.connectionState === "failed") {
         setPeerError(new Error("peer disconnected"));
      }
 }

In this PR I tried a more general approach and just report the event change to manage it in the parent component, but maybe you come up with a better idea. Probably some work must be done in useMaster too

cyuste commented 2 years ago

Hi @pdcarroll ,

I think you are right, let me try it but your suggestion looks better indeed.

I have created #19 to explain myself better regarding channel change

Thank you very much for your help