§
    º¦-e   ã                  ó„   — d Z ddlmZ ddlZ ej        e¦  «        ZddlmZm	Z	 ddl
mZ ddlmZ d	Z G d
„ d¦  «        ZdS )zR Encapsulate handling of all Bokeh Protocol messages a Bokeh server may
receive.

é    )ÚannotationsN)ÚAnyÚCallableé   )ÚProtocolErroré   )ÚServerSession)ÚProtocolHandlerc                  ó2   — e Zd ZU dZded<   d
d„Zd„ Zd„ Zd	S )r
   aÇ   A Bokeh server may be expected to receive any of the following protocol
    messages:

    * ``PATCH-DOC``
    * ``PULL-DOC-REQ``
    * ``PUSH-DOC``
    * ``SERVER-INFO-REQ``

    The job of ``ProtocolHandler`` is to direct incoming messages to the right
    specialized handler for each message type. When the server receives a new
    message on a connection it will call ``handler`` with the message and the
    connection that the message arrived on. Most messages are ultimately
    handled by the ``ServerSession`` class, but some simpler messages types
    such as ``SERVER-INFO-REQ`` may be handled directly by ``ProtocolHandler``.

    Any unexpected messages will result in a ``ProtocolError``.

    zdict[str, Callable[..., Any]]Ú	_handlersÚreturnÚNonec                óª   — i | _         t          j        | j         d<   t          j        | j         d<   t          j        | j         d<   | j        | j         d<   d S )NzPULL-DOC-REQzPUSH-DOCz	PATCH-DOCzSERVER-INFO-REQ)r   r	   ÚpullÚpushÚpatchÚ_server_info_req)Úselfs    ú=lib/python3.11/site-packages/bokeh/server/protocol_handler.pyÚ__init__zProtocolHandler.__init__A   sL   € ØˆŒå)6Ô);ˆŒ~Ñ&Ý%2Ô%7ˆŒzÑ"Ý&3Ô&9ˆŒ{Ñ#Ø,0Ô,AˆŒÐ(Ñ)Ð)Ð)ó    c              ƒ  óŠ  K  — | j                              |j        ¦  «        }|€| j                              |j        ¦  «        }|€t          |› d¦  «        ‚	  |||¦  «        ƒ d{V —†}nX# t          $ rK}t
                               d||d¬¦  «         |                     |t          |¦  «        ¦  «        }Y d}~nd}~ww xY w|S )aI   Delegate a received message to the appropriate handler.

        Args:
            message (Message) :
                The message that was receive that needs to be handled

            connection (ServerConnection) :
                The connection that received this message

        Raises:
            ProtocolError

        Nz not expected on serverz/error handling message
 message: %r 
 error: %rT)Úexc_info)r   ÚgetÚmsgtyper   Ú	ExceptionÚlogÚerrorÚrepr)r   ÚmessageÚ
connectionÚhandlerÚworkÚes         r   ÚhandlezProtocolHandler.handleI   sñ   è è € ð ”.×$Ò$ W¤_Ñ5Ô5ˆàˆ?Ø”n×(Ò(¨¬Ñ9Ô9ˆGàˆ?Ý 7Ð CÐ CÐ CÑDÔDÐDð	6Ø ˜ ¨*Ñ5Ô5Ð5Ð5Ð5Ð5Ð5Ð5ˆDˆDøÝð 	6ð 	6ð 	6ÝIŠIÐIØ˜q¨4ð ñ 1ô 1ð 1à×#Ò# G­T°!©W¬WÑ5Ô5ˆDˆDˆDˆDˆDˆDøøøøð	6øøøð ˆs   ÁA+ Á+
C Á5AB;Â;C c              ƒ  óR   K  — |j                              d|j        d         ¦  «        S )NzSERVER-INFO-REPLYÚmsgid)ÚprotocolÚcreateÚheader)r   r    r!   s      r   r   z ProtocolHandler._server_info_reqh   s'   è è € ØÔ"×)Ò)Ð*=¸w¼~ÈgÔ?VÑWÔWÐWr   N)r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__r   r%   r   © r   r   r
   r
   +   si   € € € € € € ðð ð& -Ð,Ð,Ñ,ðBð Bð Bð Bðð ð ð>Xð Xð Xð Xð Xr   r
   )r.   Ú
__future__r   ÚloggingÚ	getLoggerr+   r   Útypingr   r   Úprotocol.exceptionsr   Úsessionr	   Ú__all__r
   r0   r   r   ú<module>r8      sÁ   ððð ð #Ð "Ð "Ð "Ð "Ð "à €€€Ø€gÔ˜Ñ!Ô!€ð !Ð  Ð  Ð  Ð  Ð  Ð  Ð  ð 0Ð /Ð /Ð /Ð /Ð /Ø "Ð "Ð "Ð "Ð "Ð "ð€ð>Xð >Xð >Xð >Xð >Xñ >Xô >Xð >Xð >Xð >Xr   