@@ -362,6 +362,10 @@ async def _send_presence(self, presence_messages: list[dict]) -> None:
362362 'presence' : presence_messages
363363 }
364364
365+ print (
366+ f"[PRESENCE DEBUG] _send_presence: Sending { len (presence_messages )} messages "
367+ f"on channel { self .channel .name } "
368+ )
365369 await self .channel .ably .connection .connection_manager .send_protocol_message (protocol_msg )
366370
367371 async def _queue_presence (self , wire_msg : dict ) -> None :
@@ -468,6 +472,10 @@ async def subscribe(self, *args) -> None:
468472 Raises:
469473 AblyException: If channel state prevents subscription
470474 """
475+ print (
476+ f"[PRESENCE DEBUG] subscribe: Called on channel { self .channel .name } , "
477+ f"channel.state={ self .channel .state } "
478+ )
471479 # RTP6d: Implicitly attach
472480 if self .channel .state in [ChannelState .INITIALIZED , ChannelState .DETACHED , ChannelState .DETACHING ]:
473481 asyncio .create_task (self .channel .attach ())
@@ -477,11 +485,13 @@ async def subscribe(self, *args) -> None:
477485 # subscribe(listener)
478486 listener = args [0 ]
479487 self ._subscriptions .on (listener )
488+ print ("[PRESENCE DEBUG] subscribe: Registered listener for all events" )
480489 elif len (args ) == 2 :
481490 # subscribe(event, listener)
482491 event = args [0 ]
483492 listener = args [1 ]
484493 self ._subscriptions .on (event , listener )
494+ print (f"[PRESENCE DEBUG] subscribe: Registered listener for event '{ event } '" )
485495 else :
486496 raise ValueError ('Invalid subscribe arguments' )
487497
@@ -524,6 +534,10 @@ def set_presence(
524534 is_sync: True if this is part of a SYNC operation
525535 sync_channel_serial: Optional sync cursor for tracking sync progress
526536 """
537+ print (
538+ f"[PRESENCE DEBUG] set_presence: Received { len (presence_set )} messages "
539+ f"on channel { self .channel .name } , is_sync={ is_sync } "
540+ )
527541 log .info (
528542 f'RealtimePresence.set_presence(): '
529543 f'received presence for { len (presence_set )} members; '
@@ -588,8 +602,16 @@ def set_presence(
588602 broadcast_messages .append (synthesized_leave )
589603
590604 # Broadcast messages to subscribers
605+ print (
606+ f"[PRESENCE DEBUG] set_presence: Broadcasting { len (broadcast_messages )} messages "
607+ f"to subscribers on channel { self .channel .name } "
608+ )
591609 for presence in broadcast_messages :
592610 action_name = PresenceAction ._action_name (presence .action ).lower ()
611+ print (
612+ f"[PRESENCE DEBUG] set_presence: Emitting '{ action_name } ' "
613+ f"for client_id={ presence .client_id } "
614+ )
593615 self ._subscriptions ._emit (action_name , presence )
594616
595617 def on_attached (self , has_presence : bool = False ) -> None :
0 commit comments