@@ -786,6 +786,7 @@ export class ActorInstance<
786
786
state : CS ,
787
787
driverId : string ,
788
788
driverState : unknown ,
789
+ subs : string [ ] | undefined ,
789
790
authData : unknown ,
790
791
) : Promise < Conn < S , CP , CS , V , I , AD , DB > > {
791
792
this . #assertReady( ) ;
@@ -814,6 +815,12 @@ export class ActorInstance<
814
815
) ;
815
816
this . #connections. set ( conn . id , conn ) ;
816
817
818
+ if ( subs ) {
819
+ for ( const sub of subs ) {
820
+ this . #addSubscription( sub , conn , true ) ;
821
+ }
822
+ }
823
+
817
824
// Add to persistence & save immediately
818
825
this . #persist. c . push ( persist ) ;
819
826
this . saveState ( { immediate : true } ) ;
@@ -875,6 +882,7 @@ export class ActorInstance<
875
882
return await this . executeAction ( ctx , name , args ) ;
876
883
} ,
877
884
onSubscribe : async ( eventName , conn ) => {
885
+ console . log ( "subscribing to event" , { eventName, connId : conn . id } ) ;
878
886
this . inspector . emitter . emit ( "eventFired" , {
879
887
type : "subscribe" ,
880
888
eventName,
@@ -1251,6 +1259,13 @@ export class ActorInstance<
1251
1259
_broadcast < Args extends Array < unknown > > ( name : string , ...args : Args ) {
1252
1260
this . #assertReady( ) ;
1253
1261
1262
+ console . log ( "broadcasting event" , {
1263
+ name,
1264
+ args,
1265
+ actorId : this . id ,
1266
+ subscriptions : this . #subscriptionIndex. size ,
1267
+ connections : this . conns . size ,
1268
+ } ) ;
1254
1269
this . inspector . emitter . emit ( "eventFired" , {
1255
1270
type : "broadcast" ,
1256
1271
eventName : name ,
0 commit comments