@@ -5,9 +5,6 @@ export const PeerService = signaling => (() => {
55 const createConnection = ( ) => new RTCPeerConnection ( {
66 offerToReceiveAudio : true ,
77 offerToReceiveVideo : true ,
8- sdpSemantics : "unified-plan" ,
9- bundlePolicy : "max-compat" ,
10- rtcpMuxPolicy : "negotiate" ,
118 iceServers : [ { urls : [ "stun:stun.stunprotocol.org:3478" , "stun:stun.l.google.com:19302" ] } ]
129 } ) ;
1310
@@ -41,9 +38,7 @@ export const PeerService = signaling => (() => {
4138 } )
4239 connection . next ( peer ) ;
4340
44- const newChannel = peer . createDataChannel ( DEFAULT_CHANNEL , {
45- reliable : false
46- } ) ;
41+ const newChannel = peer . createDataChannel ( DEFAULT_CHANNEL ) ;
4742 newChannel . addEventListener ( "message" , ( { data} ) => {
4843 messages . next ( data ) ;
4944 } ) ;
@@ -61,21 +56,21 @@ export const PeerService = signaling => (() => {
6156
6257 const sendMessage = data => {
6358 if ( dataChannel . value ?. readyState === 'open' ) {
64- dataChannel . value ? .send ( JSON . stringify ( data ) )
59+ dataChannel . value . send ( JSON . stringify ( data ) )
6560 }
6661 } ;
6762
6863 const sendOffer = id => {
69- connection . value ?. createOffer ( ) . then ( description => {
70- connection . value ? .setLocalDescription ( description ) . then ( ( ) => {
64+ connection . value ?. createOffer ( { iceRestart : connection . value . iceRestart } ) . then ( description => {
65+ connection . value . setLocalDescription ( description ) . then ( ( ) => {
7166 signaling . offer ( id , description . sdp ) ;
7267 } ) . catch ( console . error ) ;
7368 } ) ;
7469 } ;
7570
7671 const sendAnswer = id => {
77- connection . value ?. createAnswer ( ) . then ( description => {
78- connection . value ? .setLocalDescription ( description ) . then ( ( ) => {
72+ connection . value ?. createAnswer ( { iceRestart : connection . value . iceRestart } ) . then ( description => {
73+ connection . value . setLocalDescription ( description ) . then ( ( ) => {
7974 signaling . answer ( id , description . sdp ) ;
8075 } ) . catch ( console . error ) ;
8176 } ) ;
@@ -98,7 +93,7 @@ export const PeerService = signaling => (() => {
9893 const onAnswerReceived = description => {
9994 const sdp = new RTCSessionDescription ( { type : "answer" , sdp : description } ) ;
10095 connection . value ?. setRemoteDescription ( sdp ) . then ( ( ) => {
101- console . log ( "Peer connection state: %s" , connection . value ? .connectionState ) ;
96+ console . log ( "Peer connection state: %s" , connection . value . connectionState ) ;
10297 } ) . catch ( console . error ) ;
10398 } ;
10499
0 commit comments