@@ -827,27 +827,26 @@ export class Chrome111
827827 }
828828
829829 async sendDataChannel ( {
830- ordered,
831- maxPacketLifeTime,
832- maxRetransmits,
833- label,
834- protocol,
830+ sctpStreamParameters,
835831 } : HandlerSendDataChannelOptions ) : Promise < HandlerSendDataChannelResult > {
836832 this . assertNotClosed ( ) ;
837833 this . assertSendDirection ( ) ;
838834
839835 const options = {
840836 negotiated : true ,
841837 id : this . _nextSendSctpStreamId ,
842- ordered,
843- maxPacketLifeTime,
844- maxRetransmits,
845- protocol,
838+ ordered : sctpStreamParameters . ordered ,
839+ maxPacketLifeTime : sctpStreamParameters . maxPacketLifeTime ,
840+ maxRetransmits : sctpStreamParameters . maxRetransmits ,
841+ protocol : sctpStreamParameters . protocol ,
846842 } ;
847843
848844 logger . debug ( 'sendDataChannel() [options:%o]' , options ) ;
849845
850- const dataChannel = this . _pc . createDataChannel ( label ! , options ) ;
846+ const dataChannel = this . _pc . createDataChannel (
847+ sctpStreamParameters . label ! ,
848+ options
849+ ) ;
851850
852851 // Increase next id.
853852 this . _nextSendSctpStreamId =
@@ -893,14 +892,14 @@ export class Chrome111
893892 this . _hasDataChannelMediaSection = true ;
894893 }
895894
896- const sctpStreamParameters : SctpStreamParameters = {
895+ const newSctpStreamParameters : SctpStreamParameters = {
897896 streamId : options . id ,
898897 ordered : options . ordered ,
899898 maxPacketLifeTime : options . maxPacketLifeTime ,
900899 maxRetransmits : options . maxRetransmits ,
901900 } ;
902901
903- return { dataChannel, sctpStreamParameters } ;
902+ return { dataChannel, sctpStreamParameters : newSctpStreamParameters } ;
904903 }
905904
906905 async receive (
@@ -1163,6 +1162,7 @@ export class Chrome111
11631162 }
11641163
11651164 async receiveDataChannel ( {
1165+ maxMessageSize,
11661166 sctpStreamParameters,
11671167 label,
11681168 protocol,
@@ -1207,19 +1207,28 @@ export class Chrome111
12071207
12081208 await this . _pc . setRemoteDescription ( offer ) ;
12091209
1210- const answer = await this . _pc . createAnswer ( ) ;
1210+ let answer = await this . _pc . createAnswer ( ) ;
1211+ const localSdpObject = sdpTransform . parse ( answer . sdp ! ) ;
1212+ const answerMediaObject = localSdpObject . media . find (
1213+ m => m . type === 'application'
1214+ ) ! ;
12111215
1212- if ( ! this . _transportReady ) {
1213- const localSdpObject = sdpTransform . parse ( answer . sdp ! ) ;
1216+ answerMediaObject . maxMessageSize = maxMessageSize ;
12141217
1218+ if ( ! this . _transportReady ) {
12151219 await this . setupTransport ( {
12161220 localDtlsRole : this . _forcedLocalDtlsRole ?? 'client' ,
12171221 localSdpObject,
12181222 } ) ;
12191223 }
12201224
1225+ answer = {
1226+ type : 'answer' ,
1227+ sdp : sdpTransform . write ( localSdpObject ) ,
1228+ } ;
1229+
12211230 logger . debug (
1222- 'receiveDataChannel() | calling pc.setRemoteDescription () [answer:%o]' ,
1231+ 'receiveDataChannel() | calling pc.setLocalDescription () [answer:%o]' ,
12231232 answer
12241233 ) ;
12251234
0 commit comments