@@ -3,7 +3,7 @@ import { pbStream } from 'it-protobuf-stream'
3
3
import { SDPHandshakeFailedError } from '../error.js'
4
4
import { type RTCPeerConnection , RTCSessionDescription } from '../webrtc/index.js'
5
5
import { Message } from './pb/message.js'
6
- import { readCandidatesUntilConnected } from './util.js'
6
+ import { getConnectionState , readCandidatesUntilConnected } from './util.js'
7
7
import type { Logger } from '@libp2p/interface'
8
8
import type { IncomingStreamData } from '@libp2p/interface-internal'
9
9
@@ -40,6 +40,8 @@ export async function handleIncomingStream ({ peerConnection, stream, signal, co
40
40
} )
41
41
}
42
42
43
+ log . trace ( 'recipient read SDP offer' )
44
+
43
45
// read an SDP offer
44
46
const pbOffer = await messageStream . read ( {
45
47
signal
@@ -49,7 +51,7 @@ export async function handleIncomingStream ({ peerConnection, stream, signal, co
49
51
throw new SDPHandshakeFailedError ( `expected message type SDP_OFFER, received: ${ pbOffer . type ?? 'undefined' } ` )
50
52
}
51
53
52
- log . trace ( 'recipient receive SDP offer %s' , pbOffer . data )
54
+ log . trace ( 'recipient received SDP offer %s' , pbOffer . data )
53
55
54
56
const offer = new RTCSessionDescription ( {
55
57
type : 'offer' ,
@@ -88,7 +90,7 @@ export async function handleIncomingStream ({ peerConnection, stream, signal, co
88
90
log
89
91
} )
90
92
} catch ( err : any ) {
91
- if ( peerConnection . connectionState !== 'connected' ) {
93
+ if ( getConnectionState ( peerConnection ) !== 'connected' ) {
92
94
log . error ( 'error while handling signaling stream from peer %a' , connection . remoteAddr , err )
93
95
94
96
peerConnection . close ( )
0 commit comments