�
���g�( � �V � d dl mZ d dlZd dlmZ d dlZddlmZ G d� de� � ZdS )� )�partialN)�json� )�Managerc �� � � e Zd ZdZdZd� fd� Z� fd�Z d� fd� Z� fd �Zd� fd
� Z d� fd� Z
� fd�Zdd
�Zd� Z
d� Z� fd�Zd� Zd� Zd� Z� fd�Z� fd�Z� fd�Zd� Z� xZS )�
PubSubManagera= Manage a client list attached to a pub/sub backend.
This is a base class that enables multiple servers to share the list of
clients, with the servers communicating events through a pub/sub backend.
The use of a pub/sub backend also allows any client connected to the
backend to emit events addressed to Socket.IO clients.
The actual backends must be implemented by subclasses, this class only
provides a pub/sub generic framework.
:param channel: The channel name on which the server sends and receives
notifications.
�pubsub�socketioFNc � �� t � � � � � || _ || _ t j � � j | _ || _ d S �N) �super�__init__�channel�
write_only�uuid�uuid4�hex�host_id�logger)�selfr r r � __class__s ��g/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/socketio/pubsub_manager.pyr zPubSubManager.__init__ sB �� �
�����������$����z�|�|�'�������� c �� �� t � � � � � | j s$| j � | j � � | _ | � � � � | j dz � � d S )Nz backend initialized.)
r
�
initializer �server�start_background_task�_thread�thread�_get_logger�info�name)r r s �r r zPubSubManager.initialize! sk �� �
���������� J��+�;�;�D�L�I�I�D�K��������� �,C� C�D�D�D�D�Dr c � �� |p|}|� d� � r't � � � ||||||�� � S |pd}|�C| j �t d� � �|�t d� � �| � ||� � } ||| f}nd}d||||||| j d�}
| � |
� � | � |
� � dS ) a/ Emit a message to a single client, a room, or all the clients
connected to the namespace.
This method takes care or propagating the message to all the servers
that are connected through the message queue.
The parameters are the same as in :meth:`.Server.emit`.
�ignore_queue�� namespace�room�skip_sid�callback�/Nz:Callbacks can only be issued from the context of a server.z'Cannot use callback without a room set.�emit)�method�event�datar&