Beispiel #1
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()
Beispiel #2
0
 def lengthLimitExceeded(self, length):
     # override hook in Int32StringReceiver base class that is fired when a message is (to be) received
     # that is larger than what we agreed to handle (by negotiation in the RawSocket opening handshake)
     emsg = 'RawSocket connection: length of received message exceeded (message was {} bytes, but current maximum is {} bytes)'.format(length, self.MAX_LENGTH)
     raise PayloadExceededError(emsg)