View Source Upgrading to v0.14

Version 0.14 removes the concept of peers from the RTC Engine meaning that RTC Engine only operates on Endpoints.

In practice, most changes come down to updating callback names.

Below, there are two PRs that update RTC Engine to the v0.14 in our demos:

RTC Engine (Elixir)

Instead of peer_id or endpoint_id use id:

- :ok = Engine.add_endpoint(state.rtc_engine, endpoint, peer_id: peer_id, node: peer_node)
+ :ok = Engine.add_endpoint(state.rtc_engine, endpoint, id: peer_id, node: peer_node)

SDK (JS)

MembraneWebRTC class was renamed to WebRTCEndpoint. It also no longer takes callbacks in the constructor. Instead, you have to subscribe for events:

- const webrtc = new MembraneWebRTC({callbacks: {}})
+ const webrtc = new WebRTCEndpoint();
callbackevent
onSendMediaEventwebrtc.on("sendMediaEvent")
onConnectionErrorwebrtc.on("connectionError")
onJoinSuccesswebrtc.on("connected")
onTrackReadywebrtc.on("trackReady")
onTrackAddedwebrtc.on("trackAdded")
onTrackRemovedwebrtc.on("trackRemoved")
onPeerJoinedwebrtc.on("endpointAdded")
onPeerLeftwebrtc.on("endpointRemoved")
onTrackUpdatedwebrtc.on("trackUpdated")
onTrackEncodingChangedtrackCtx.on("encodingChanged")
onJoinErrorremoved

The process of "connecting" SDK to the RTC Engine endpoint is all about sending a single message indicating SDK readiness. Therefore, instead of using onJoinError, a user is expected to observe its transport status (in most cases WS connection) and can add tracks as soon as connect function has been called.

It's important that endpointAdded event will be emitted for every endpoint added to the engine. You can filter out endpoints by their type i.e.

webrtc.on("endpointAdded", (endpoint: Endpoint) => {
   if (endpoint.type === "webrtc") {
    // do something
   }
});

Connecting

- webrtc.join(peerMetadata);
+ webrtc.connect(metadata);

Leaving

- webrtc.leave();
+ webrtc.disconnect();