File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -316,7 +316,18 @@ impl RTCDataChannel {
316
316
let mut buffer = vec ! [ 0u8 ; DATA_CHANNEL_BUFFER_SIZE as usize ] ;
317
317
loop {
318
318
let ( n, is_string) = tokio:: select! {
319
- _ = notify_rx. notified( ) => break ,
319
+ _ = notify_rx. notified( ) => {
320
+ ready_state. store( RTCDataChannelState :: Closed as u8 , Ordering :: SeqCst ) ;
321
+ let on_close_handler2 = Arc :: clone( & on_close_handler) ;
322
+ tokio:: spawn( async move {
323
+ if let Some ( handler) = & * on_close_handler2. load( ) {
324
+ let mut f = handler. lock( ) . await ;
325
+ f( ) . await ;
326
+ }
327
+ } ) ;
328
+
329
+ break ;
330
+ }
320
331
result = data_channel. read_data_channel( & mut buffer) => {
321
332
match result{
322
333
// EOF (`data_channel` was either closed or the underlying stream got
You can’t perform that action at this time.
0 commit comments