Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _unregister(self, registration):
"""
Called from :meth:`autobahn.wamp.protocol.Registration.unregister`
"""
assert(isinstance(registration, Registration))
assert registration.active
assert(registration.id in self._registrations)
if not self._transport:
raise exception.TransportLost()
request_id = self._request_id_gen.next()
on_reply = txaio.create_future()
self._unregister_reqs[request_id] = UnregisterRequest(request_id, on_reply, registration.id)
msg = message.Unregister(request_id, registration.id)
self._transport.send(msg)
return on_reply
def onDisconnect(self):
"""
Implements :func:`autobahn.wamp.interfaces.ISession.onDisconnect`
"""
# fire TransportLost on any _still_ outstanding requests
# (these should have been already cleaned up in onLeave() - when
# this actually has fired)
exc = exception.TransportLost()
self._errback_outstanding_requests(exc)
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("WAMP serialization error ({0})".format(e))
else:
self.sendMessage(payload, isBinary)
else:
raise TransportLost()
def close(self):
"""
Implements :func:`autobahn.wamp.interfaces.ITransport.close`
"""
if self.isOpen():
self.onClose(True, 1000, u"session closed")
self._receive._kill()
del self._parent._transports[self._transport_id]
else:
raise TransportLost()
api_id=hl(uuid.UUID(bytes=api_id)),
price=hl(str(int(price / 10 ** 18) if price is not None else 0) + ' XBR', color='magenta'),
delegate=hl(binascii.b2a_hex(delegate).decode()),
prefix=hl(prefix))
self.log.debug('offer={offer}', offer=offer)
break
except ApplicationError as e:
if e.error == 'wamp.error.no_such_procedure':
self.log.warn('xbr.marketmaker.offer: procedure unavailable!')
else:
self.log.failure()
break
except TransportLost:
self.log.warn('TransportLost while calling xbr.marketmaker.offer!')
break
except:
self.log.failure()
retries -= 1
self.log.warn('Failed to place offer for key! Retrying {retries}/5 ..', retries=retries)
await asyncio.sleep(1)
def abort(self):
"""
Implements :func:`autobahn.wamp.interfaces.ITransport.abort`
"""
if self.isOpen():
self._bailout(protocol.WebSocketProtocol.CLOSE_STATUS_CODE_GOING_AWAY)
else:
raise TransportLost()
def abort(self):
"""
Implements :func:`autobahn.wamp.interfaces.ITransport.abort`
"""
if self.isOpen():
if hasattr(self.transport, 'abortConnection'):
# ProcessProtocol lacks abortConnection()
self.transport.abortConnection()
else:
self.transport.loseConnection()
else:
raise TransportLost()
def abort(self):
"""
Implements :func:`autobahn.wamp.interfaces.ITransport.abort`
"""
if self.isOpen():
self.onClose(True, 1000, u"session aborted")
self._receive._kill()
del self._parent._transports[self._transport_id]
else:
raise TransportLost()
def register(self, endpoint, procedure=None, options=None, prefix=None):
"""
Implements :func:`autobahn.wamp.interfaces.ICallee.register`
"""
assert((callable(endpoint) and procedure is not None) or hasattr(endpoint, '__class__'))
assert(procedure is None or type(procedure) == six.text_type)
assert(options is None or isinstance(options, types.RegisterOptions))
assert prefix is None or isinstance(prefix, six.text_type)
if not self._transport:
raise exception.TransportLost()
def _register(obj, fn, procedure, options):
message.check_or_raise_uri(procedure,
message='{}.register()'.format(self.__class__.__name__),
strict=False,
allow_empty_components=True,
allow_none=False)
request_id = self._request_id_gen.next()
on_reply = txaio.create_future()
endpoint_obj = Endpoint(fn, obj, options.details_arg if options else None)
if prefix is not None:
procedure = u"{}{}".format(prefix, procedure)
self._register_reqs[request_id] = RegisterRequest(request_id, on_reply, procedure, endpoint_obj)
if options:
def send(self, msg):
"""
Implements :func:`autobahn.wamp.interfaces.ITransport.send`
"""
if self.isOpen():
self.log.trace("WampRawSocketProtocol: TX WAMP message: {msg}", msg=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.trace("WampRawSocketProtocol: TX octets: {octets}", octets=_LazyHexFormatter(payload))
else:
raise TransportLost()