@@ -37,6 +37,7 @@ type Value = { [key: string]: any };
37
37
// Also, we don't implement complete object delete yet so instead we
38
38
// set the data field to null, which clears all state about and
39
39
// object and makes it easy to know to ignore it.
40
+ // We also use this time for deleting ephemeral messages.
40
41
const GC_DEBOUNCE_MS = 10000 ;
41
42
42
43
// If for some reason GC needs to be deleted, e.g., maybe you
@@ -475,11 +476,16 @@ scat.x, scat.y = np.random.rand(2, 50)
475
476
}
476
477
const [ string_id , model_id , type ] = JSON . parse ( key ) ;
477
478
if ( ! activeIds . has ( model_id ) ) {
479
+ // Delete this model from the table (or as close to delete as we have).
478
480
this . table . set (
479
481
{ string_id, type, model_id, data : null } ,
480
482
"none" ,
481
483
false ,
482
484
) ;
485
+
486
+ // Also delete buffers for this model, which are stored in memory, and
487
+ // won't be requested again.
488
+ delete this . buffers [ model_id ] ;
483
489
}
484
490
} ) ;
485
491
await this . table . save ( ) ;
@@ -682,6 +688,8 @@ scat.x, scat.y = np.random.rand(2, 50)
682
688
// the other data; otherwise, deserialization on
683
689
// the client side can't work, since it is missing
684
690
// the data it needs.
691
+ // This happens with method "update". With method="custom",
692
+ // there is just an array of buffers and no buffer_paths at all.
685
693
if ( content . data . buffer_paths ?. length > 0 ) {
686
694
// Deal with binary buffers:
687
695
dbg ( "setting binary buffers" ) ;
@@ -696,9 +704,19 @@ scat.x, scat.y = np.random.rand(2, 50)
696
704
switch ( content . data . method ) {
697
705
case "custom" :
698
706
const message = content . data . content ;
699
- dbg ( "custom message" , message ) ;
700
- // NOTE: any buffers that are part of this comm message
701
- // already got set above.
707
+ const { buffers } = msg ;
708
+ dbg ( "custom message" , {
709
+ message,
710
+ buffers : `${ buffers ?. length ?? "no" } buffers` ,
711
+ } ) ;
712
+ if (
713
+ buffers != null &&
714
+ buffers . length > 0 &&
715
+ content . data . buffer_paths == null
716
+ ) {
717
+ // TODO
718
+ dbg ( "custom message -- there are BUFFERS -- NOT implemented!!" ) ;
719
+ }
702
720
// We now send the message.
703
721
this . sendCustomMessage ( model_id , message , false ) ;
704
722
break ;
@@ -893,10 +911,14 @@ with out:
893
911
via the table for a few seconds, then remove it. Any clients
894
912
that are connected while we do this can react, and any that aren't
895
913
just don't get the message (which is presumably fine).
914
+
915
+ Some widgets like ipympl use this to initialize state, so when a new
916
+ client connects, it requests a message describing the plot, and everybody
917
+ receives it.
896
918
*/
897
919
898
920
this . set ( model_id , "message" , message , fire_change_event ) ;
899
- await delay ( 3000 ) ;
921
+ await delay ( GC_DEBOUNCE_MS ) ;
900
922
// Actually, delete is not implemented for synctable, so for
901
923
// now we just set it to an empty message.
902
924
this . set ( model_id , "message" , { } , fire_change_event ) ;
0 commit comments