(self, sock=None, data=bytearray(), *args, **kwargs)
Creates a new codec.

        :param sock: the socket used in Read and write events
            (if used in a server, else None)
Creates a new codec.
Creates a new codec .
def __init__(self, sock=None, data=bytearray(), *args, **kwargs):
        """
        Creates a new codec.

        :param sock: the socket used in Read and write events
            (if used in a server, else None)
        """
        super(WebSocketCodec, self).__init__(*args, **kwargs)

        self._sock = sock

        self._pending_payload = bytearray()
        self._pending_type = None
        self._close_received = False
        self._close_sent = False

        messages = self._parse_messages(bytearray(data))
        for message in messages:
            if self._sock is not None:
                self.fire(read(self._sock, message))
            else:
                self.fire(read(message))
def __init__ ( self , sock = None , data = bytearray ( ) , * args , * * kwargs ) : super ( WebSocketCodec , self ) . __init__ ( * args , * * kwargs ) self . _sock = sock self . _pending_payload = bytearray ( ) self . _pending_type = None self . _close_received = False self . _close_sent = False messages = self . _parse_messages ( bytearray ( data ) ) for message in messages : if self . _sock is not None : self . fire ( read ( self . _sock , message ) ) else : self . fire ( read ( message ) )