
    i}	                     Z    d dl Z d dlZd dlmZ ddlmZ ddlmZ ddlm	Z	  G d de
      Zy)	    N)Any   )InvocationClientStreamMessage)StreamItemMessage)CompletionClientStreamMessagec                   4    e Zd ZdZd Zd ZdefdZd Zd Z	y)	SubjectaW  Client to server streaming
    https://docs.microsoft.com/en-gb/aspnet/core/signalr/streaming?view=aspnetcore-5.0#client-to-server-streaming
    items = list(range(0,10))
    subject = Subject()
    connection.send("UploadStream", subject)
    while(len(self.items) > 0):
        subject.next(str(self.items.pop()))
    subject.complete()
    c                     d | _         d | _        t        t        j                               | _        t        j                         | _        d| _	        y )N
   )

connectiontargetstruuiduuid4invocation_id	threadingLocklock_timeoutselfs    L/home/work/apex_v16/venv/lib/python3.12/site-packages/signalrcore/subject.py__init__zSubject.__init__   s8     .NN$	    c                 b    | j                   | j                  | j                  t        d      y)zEnsures that invocation streaming object is correct

        Raises:
            ValueError: if object is not valid, exception will be raised
        Nz`subject must be passed as an argument to a send function. hub_connection.send([method],[subject])r   r   r   
ValueErrorr   s    r   checkzSubject.check   s;     ??";;&%%-;< < .r   itemc                 $   | j                          | j                  j                  | j                        sJ d       | j                  j
                  j                  t        | j                  |             | j                  j                          y)zgSend next item to the server

        Args:
            item (any): Item that will be streamed
        timeoutzNext raised exceptionN)
r   r   acquirer   r   	transportsendr   r   release)r   r   s     r   nextzSubject.next(   st     	

yy   7 	$#	$7!!&&'8""( 	 			r   c                 <   | j                          | j                  j                  | j                        sJ d       | j                  j
                  j                  t        | j                  g| j                  g              | j                  j                          y)zStarts streaming
        r    zStart raised exceptionN)r   r   r"   r   r   r#   r$   r   r   r   r%   r   s    r   startzSubject.start6   s~     	

yy   7 	%$	%7!!&&-''(KK	
 			r   c                 "   | j                          | j                  j                  | j                        sJ d       | j                  j
                  j                  t        | j                               | j                  j                          y)zFinish streaming
        r    zComplete raised exceptionN)
r   r   r"   r   r   r#   r$   r   r   r%   r   s    r   completezSubject.completeC   so     	

yy   7 	('	(7!!&&'D""($ 	%		r   N)
__name__
__module____qualname____doc__r   r   r   r&   r(   r*    r   r   r	   r	   	   s'    < r   r	   )r   r   typingr   messages.invocation_messager   messages.stream_item_messager   messages.completion_messager   objectr	   r/   r   r   <module>r5      s%       F ; FBf Br   