Ejemplo n.º 1
0
 def send(self, msg):
     """
     Implements :func:`autobahn.wamp.interfaces.ITransport.send`
     """
     if self.isOpen():
         try:
             self.log.debug(
                 "WampLongPoll: TX {octets}",
                 octets=_LazyHexFormatter(msg),
             )
             payload, isBinary = self._serializer.serialize(msg)
         except Exception as e:
             # all exceptions raised from above should be serialization errors ..
             f = create_failure()
             self.log.error(
                 "Unable to serialize WAMP application payload: {msg}",
                 msg=failure_message(f),
             )
             self.log.debug("{tb}", tb=failure_format_traceback(f))
             raise SerializationError(
                 "unable to serialize WAMP application payload ({0})".
                 format(e))
         else:
             self._receive.queue(payload)
     else:
         raise TransportLost()
Ejemplo n.º 2
0
 def send(self, msg):
     """
     Implements :func:`autobahn.wamp.interfaces.ITransport.send`
     """
     if self.isOpen():
         self.log.trace('{klass}.send() (serializer={serializer}): TX WAMP message: "{msg}"',
                        klass=self.__class__.__name__, msg=msg, serializer=self._serializer)
         try:
             payload, _ = self._serializer.serialize(msg)
         except SerializationError as e:
             # all exceptions raised from above should be serialization errors ..
             raise SerializationError("WampRawSocketProtocol: unable to serialize WAMP application payload ({0})".format(e))
         else:
             payload_len = len(payload)
             if 0 < self._max_len_send < payload_len:
                 emsg = 'tried to send RawSocket message with size {} exceeding payload limit of {} octets'.format(
                     payload_len, self._max_len_send)
                 self.log.warn(emsg)
                 raise PayloadExceededError(emsg)
             else:
                 self.sendString(payload)
                 self.log.trace('{klass}.send(): TX {octets} octets',
                                klass=self.__class__.__name__, octets=_LazyHexFormatter(payload))
     else:
         raise TransportLost()
Ejemplo n.º 3
0
    def decode(self, is_originating, uri, encoded_payload):
        # Autobahn has received a custom payload.
        # convert it into a tuple: (uri, args, kwargs)
        if encoded_payload.enc_algo != ENC_ALGO:
            raise SerializationError('Unrecognized payload encoding algorithm: %s' % encoded_payload.enc_algo)

        args, kwargs = cbor2.loads(encoded_payload.payload, tag_hook=tag_decoder)
        return uri, args, kwargs
Ejemplo n.º 4
0
 def send(self, msg):
     """
     Implements :func:`autobahn.wamp.interfaces.ITransport.send`
     """
     if self.isOpen():
         try:
             self.log.debug("WampLongPoll: TX {0}".format(msg))
             payload, isBinary = self._serializer.serialize(msg)
         except Exception as e:
             # all exceptions raised from above should be serialization errors ..
             raise SerializationError("unable to serialize WAMP application payload ({0})".format(e))
         else:
             self._receive.queue(payload)
     else:
         raise TransportLost()
Ejemplo n.º 5
0
 def send(self, msg):
    """
    Implements :func:`autobahn.wamp.interfaces.ITransport.send`
    """
    if self.isOpen():
       try:
          if self.factory.debug_wamp:
             print("TX {0}".format(msg))
          payload, isBinary = self._serializer.serialize(msg)
       except Exception as e:
          ## all exceptions raised from above should be serialization errors ..
          raise SerializationError("Unable to serialize WAMP application payload ({0})".format(e))
       else:
          self.sendMessage(payload, isBinary)
    else:
       raise TransportLost()
Ejemplo n.º 6
0
 def send(self, msg):
     """
     Implements :func:`autobahn.wamp.interfaces.ITransport.send`
     """
     if self.isOpen():
         self.log.trace("WampRawSocketProtocol (serializer={serializer}): TX WAMP message: {msg}", msg=msg, serializer=self._serializer)
         try:
             payload, _ = self._serializer.serialize(msg)
         except Exception as e:
             # all exceptions raised from above should be serialization errors ..
             raise SerializationError("WampRawSocketProtocol: unable to serialize WAMP application payload ({0})".format(e))
         else:
             self.sendString(payload)
             self.log.trace("WampRawSocketProtocol: TX octets: {octets}", octets=_LazyHexFormatter(payload))
     else:
         raise TransportLost()
Ejemplo n.º 7
0
 def send(self, msg):
    """
    Implements :func:`autobahn.wamp.interfaces.ITransport.send`
    """
    if self.isOpen():
       if self.factory.debug:
          log.msg("TX WAMP message: {}".format(msg))
       try:
          bytes, _ = self.factory._serializer.serialize(msg)
       except Exception as e:
          ## all exceptions raised from above should be serialization errors ..
          raise SerializationError("Unable to serialize WAMP application payload ({})".format(e))
       else:
          self.sendString(bytes)
          if self.factory.debug:
             log.msg("TX octets: {}".format(binascii.hexlify(bytes)))
    else:
       raise TransportLost()
 def send(self, msg):
     """
     Implements :func:`autobahn.wamp.interfaces.ITransport.send`
     """
     if self.isOpen():
         self.log.debug(
             "WampRawSocketProtocol: TX WAMP message: {0}".format(msg))
         try:
             payload, _ = self._serializer.serialize(msg)
         except Exception as e:
             # all exceptions raised from above should be serialization errors ..
             raise SerializationError(
                 "WampRawSocketProtocol: unable to serialize WAMP application payload ({0})"
                 .format(e))
         else:
             self.sendString(payload)
             self.log.debug("WampRawSocketProtocol: TX octets: {0}".format(
                 binascii.hexlify(payload)))
     else:
         raise TransportLost()
Ejemplo n.º 9
0
 def send(self, msg):
     """
     Implements :func:`autobahn.wamp.interfaces.ITransport.send`
     """
     if self.isOpen():
         try:
             self.log.trace(
                 "WAMP SEND: message={message}, session={session}, authid={authid}",
                 authid=self._session._authid,
                 session=self._session._session_id,
                 message=msg,
             )
             payload, isBinary = self._serializer.serialize(msg)
         except Exception as e:
             self.log.error("WAMP message serialization error")
             # all exceptions raised from above should be serialization errors ..
             raise SerializationError(u"WAMP message serialization error: {0}".format(e))
         else:
             self.sendMessage(payload, isBinary)
     else:
         raise TransportLost()