예제 #1
0
    def __init__(self, factory, serializers=None):
        """

        :param factory: A callable that produces instances that implement
            :class:`autobahn.wamp.interfaces.ITransportHandler`
        :type factory: callable
        :param serializers: A list of WAMP serializers to use (or None for default
           serializers). Serializers must implement
           :class:`autobahn.wamp.interfaces.ISerializer`.
        :type serializers: list
        """
        if callable(factory):
            self._factory = factory
        else:
            self._factory = lambda: factory

        # when no serializers were requested specifically, then support
        # all that are available
        if serializers is None:
            serializers = get_serializers()

            if not serializers:
                raise Exception("could not import any WAMP serializers")

        self._serializers = {ser.RAWSOCKET_SERIALIZER_ID: ser for ser in serializers}
예제 #2
0
    def __init__(self, factory, serializer=None):
        """

        :param factory: A callable that produces instances that implement
            :class:`autobahn.wamp.interfaces.ITransportHandler`
        :type factory: callable
        :param serializer: The WAMP serializer to use (or None for default
           serializer). Serializers must implement
           :class:`autobahn.wamp.interfaces.ISerializer`.
        :type serializer: obj
        """
        if callable(factory):
            self._factory = factory
        else:
            self._factory = lambda: factory

        # when no serializer was requested specifically, use the first
        # one available
        if serializer is None:
            serializers = get_serializers()
            if serializers:
                serializer = serializers[0]

        if serializer is None:
            raise Exception("could not import any WAMP serializer")

        self._serializer = serializer
예제 #3
0
    def __init__(self, factory, serializers=None):
        """

        :param factory: A callable that produces instances that implement
            :class:`autobahn.wamp.interfaces.ITransportHandler`
        :type factory: callable

        :param serializers: A list of WAMP serializers to use (or ``None``
            for all available serializers).
        :type serializers: list of objects implementing
            :class:`autobahn.wamp.interfaces.ISerializer`
        """
        if callable(factory):
            self._factory = factory
        else:
            self._factory = lambda: factory

        # when no serializers were requested specifically, then support
        # all that are available
        if serializers is None:
            serializers = get_serializers()

            if not serializers:
                raise Exception("could not import any WAMP serializers")

        self._serializers = {
            ser.RAWSOCKET_SERIALIZER_ID: ser
            for ser in serializers
        }
예제 #4
0
    def __init__(self, factory, serializer=None):
        """

        :param factory: A callable that produces instances that implement
            :class:`autobahn.wamp.interfaces.ITransportHandler`
        :type factory: callable

        :param serializer: The WAMP serializer to use (or ``None`` for
           "best" serializer, chosen as the first serializer available from
           this list: CBOR, MessagePack, UBJSON, JSON).
        :type serializer: object implementing :class:`autobahn.wamp.interfaces.ISerializer`
        """
        if callable(factory):
            self._factory = factory
        else:
            self._factory = lambda: factory

        # when no serializer was requested specifically, use the first
        # one available
        if serializer is None:
            serializers = get_serializers()
            if serializers:
                serializer = serializers[0]()

        if serializer is None:
            raise Exception("could not import any WAMP serializer")

        self._serializer = serializer
예제 #5
0
    def __init__(self, factory, serializer=None):
        """

        :param factory: A callable that produces instances that implement
            :class:`autobahn.wamp.interfaces.ITransportHandler`
        :type factory: callable

        :param serializer: The WAMP serializer to use (or ``None`` for
           "best" serializer, chosen as the first serializer available from
           this list: CBOR, MessagePack, UBJSON, JSON).
        :type serializer: object implementing :class:`autobahn.wamp.interfaces.ISerializer`
        """
        if callable(factory):
            self._factory = factory
        else:
            self._factory = lambda: factory

        # when no serializer was requested specifically, use the first
        # one available
        if serializer is None:
            serializers = get_serializers()
            if serializers:
                serializer = serializers[0]()

        if serializer is None:
            raise Exception("could not import any WAMP serializer")

        self._serializer = serializer
예제 #6
0
    def __init__(self, factory, serializer=None):
        """

        :param factory: A callable that produces instances that implement
            :class:`autobahn.wamp.interfaces.ITransportHandler`
        :type factory: callable
        :param serializer: The WAMP serializer to use (or None for default
           serializer). Serializers must implement
           :class:`autobahn.wamp.interfaces.ISerializer`.
        :type serializer: obj
        """
        if callable(factory):
            self._factory = factory
        else:
            self._factory = lambda: factory

        # when no serializer was requested specifically, use the first
        # one available
        if serializer is None:
            serializers = get_serializers()
            if serializers:
                serializer = serializers[0]

        if serializer is None:
            raise Exception("could not import any WAMP serializer")

        self._serializer = serializer
예제 #7
0
 def test_sers(self):
     serializers = get_serializers()
     self.assertTrue(len(serializers) > 0)
     m = serializers[0]().serialize(message.Abort(u'close'))
     print(m)
     self.assertTrue(m)
def test_sers(event_loop):
    serializers = get_serializers()
    assert len(serializers) > 0
    m = serializers[0]().serialize(message.Abort('close'))
    assert m
 def test_sers(self):
     serializers = get_serializers()
     self.assertTrue(len(serializers) > 0)
     m = serializers[0]().serialize(message.Abort(u'close'))
     print(m)
     self.assertTrue(m)