Exemplo n.º 1
0
    MIME type announced in HTTP request/response headers when running
    WAMP-over-Longpoll HTTP fallback.
    """
    def __init__(self, batched=False):
        """
        Ctor.

        :param batched: Flag to control whether to put this serialized into batched mode.
        :type batched: bool
        """
        Serializer.__init__(self, JsonObjectSerializer(batched=batched))
        if batched:
            self.SERIALIZER_ID = u"json.batched"


ISerializer.register(JsonSerializer)

# MsgPack serialization depends on the `u-msgpack` package being available
# https://pypi.python.org/pypi/u-msgpack-python
# https://github.com/vsergeev/u-msgpack-python
#
try:
    import umsgpack
except ImportError:
    pass
else:

    class MsgPackObjectSerializer(object):

        BINARY = True
        """
Exemplo n.º 2
0
    MIME type announced in HTTP request/response headers when running
    WAMP-over-Longpoll HTTP fallback.
    """
    def __init__(self, batched=False):
        """
        Ctor.

        :param batched: Flag to control whether to put this serialized into batched mode.
        :type batched: bool
        """
        Serializer.__init__(self, JsonObjectSerializer(batched=batched))
        if batched:
            self.SERIALIZER_ID = "json.batched"


ISerializer.register(JsonSerializer)

##
# MsgPack serialization depends on the `msgpack` package being available
##
try:
    import msgpack
except ImportError:
    pass
else:

    class MsgPackObjectSerializer(object):

        BINARY = True
        """
      Flag that indicates whether this serializer needs a binary clean transport.
Exemplo n.º 3
0
    WAMP-over-Longpoll HTTP fallback.
    """

    def __init__(self, batched=False):
        """
        Ctor.

        :param batched: Flag to control whether to put this serialized into batched mode.
        :type batched: bool
        """
        Serializer.__init__(self, JsonObjectSerializer(batched=batched))
        if batched:
            self.SERIALIZER_ID = "json.batched"


ISerializer.register(JsonSerializer)


##
# MsgPack serialization depends on the `msgpack` package being available
##
try:
    import msgpack
except ImportError:
    pass
else:

    class MsgPackObjectSerializer(object):

        BINARY = True
        """
Exemplo n.º 4
0
    WAMP-over-Longpoll HTTP fallback.
    """

    def __init__(self, batched=False):
        """
        Ctor.

        :param batched: Flag to control whether to put this serialized into batched mode.
        :type batched: bool
        """
        Serializer.__init__(self, JsonObjectSerializer(batched=batched))
        if batched:
            self.SERIALIZER_ID = u"json.batched"


ISerializer.register(JsonSerializer)
SERID_TO_SER[JsonSerializer.SERIALIZER_ID] = JsonSerializer


_HAS_MSGPACK = False
_USE_UMSGPACK = platform.python_implementation() == u'PyPy' or 'AUTOBAHN_USE_UMSGPACK' in os.environ

if not _USE_UMSGPACK:
    try:
        # on CPython, use an impl. with native extension:
        # https://pypi.org/project/msgpack/
        # https://github.com/msgpack/msgpack-python
        import msgpack
    except ImportError:
        pass
    else:
Exemplo n.º 5
0
    WAMP-over-Longpoll HTTP fallback.
    """

    def __init__(self, batched=False):
        """
        Ctor.

        :param batched: Flag to control whether to put this serialized into batched mode.
        :type batched: bool
        """
        Serializer.__init__(self, JsonObjectSerializer(batched=batched))
        if batched:
            self.SERIALIZER_ID = u"json.batched"


ISerializer.register(JsonSerializer)
SERID_TO_SER[JsonSerializer.SERIALIZER_ID] = JsonSerializer


_HAS_MSGPACK = False
if platform.python_implementation() == u'CPython':
    try:
        # on CPython, use an impl. with native extension:
        # https://pypi.org/project/msgpack/
        # https://github.com/msgpack/msgpack-python
        import msgpack
    except ImportError:
        pass
    else:
        _HAS_MSGPACK = True
        _packb = lambda obj: msgpack.packb(obj, use_bin_type=True)  # noqa
Exemplo n.º 6
0
    WAMP-over-Longpoll HTTP fallback.
    """

    def __init__(self, batched=False):
        """
        Ctor.

        :param batched: Flag to control whether to put this serialized into batched mode.
        :type batched: bool
        """
        Serializer.__init__(self, JsonObjectSerializer(batched=batched))
        if batched:
            self.SERIALIZER_ID = u"json.batched"


ISerializer.register(JsonSerializer)


#
# MsgPack serialization depends on the `msgpack` package being available
#
try:
    import msgpack
except ImportError:
    pass
else:

    class MsgPackObjectSerializer(object):

        BINARY = True
        """
Exemplo n.º 7
0
        self.protocol.onMessage([opcode] + list(args))

    def realm_allowed(self, realm):
        return True

    def close_session(self):
        self.session_lost()

    def method_uri_allowed(self, method, uri):
        return True


class PythonObjectSerializer:
    NAME = "python"

    def serialize(self, obj):
        return obj

    def unserialize(self, payload):
        return [payload]


IObjectSerializer.register(PythonObjectSerializer)


class PythonSerializer(Serializer):
    SERIALIZER_ID = "python"


ISerializer.register(PythonSerializer)
Exemplo n.º 8
0
    """
    ID used as part of the WebSocket subprotocol name to identify the
    serializer with WAMP-over-WebSocket.
    """

    RAWSOCKET_SERIALIZER_ID = 1
    """
    ID used in lower four bits of second octet in RawSocket opening
    handshake identify the serializer with WAMP-over-RawSocket.
    """

    MIME_TYPE = u"application/json"
    """
    MIME type announced in HTTP request/response headers when running
    WAMP-over-Longpoll HTTP fallback.
    """

    def __init__(self, batched=False):
        """
        Ctor.

        :param batched: Flag to control whether to put this serialized into batched mode.
        :type batched: bool
        """
        Serializer.__init__(self, JsonObjectSerializer(batched=batched))
        if batched:
            self.SERIALIZER_ID = u"json.batched"


ISerializer.register(JsonSerializer)