Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@handler('hello')
def _on_hello(self):
return 'hello'
@handler("read")
def _on_read(self, *args):
if len(args) == 1:
# Client read
data, = args
lines, self.buffer = self.splitter(data, self.buffer)
[self.fire(line(x)) for x in lines]
else:
# Server read
sock, data = args
lines, buffer = self.splitter(data, self.getBuffer(sock))
self.updateBuffer(sock, buffer)
[self.fire(line(sock, x)) for x in lines]
@handler("write")
def write(self, sock, data):
self.fire(write(data))
@handler("started", filter=True, target="*")
def _on_started(self, component, mode):
if self._poller is None:
self._poller = self._PollerComponent()
self._poller.register(self.root)
self._poller.addReader(self, self._sock)
return True
@handler("ready")
def ready(self, component):
if self._poller is not None and self._connected:
self._poller.addReader(self, self._sock)
@handler("signal")
def _on_signal(self, *args, **kwargs):
"""signal Event Handler"""
self.fire(close())
Timer(3, terminate()).register(self)
@handler("request_success") # noqa
def _on_request_success(self, e, value):
"""
Handler for the ``RequestSuccess`` event that is automatically
generated after all handlers for a
:class:`~circuits.web.events.Request` event have been invoked
successfully.
:param e: the successfully handled ``Request`` event (having
as attributes the associated
:class:`~circuits.web.wrappers.Request` and
:class:`~circuits.web.wrappers.Response` objects).
:param value: the value(s) returned by the invoked handler(s).
This handler converts the value(s) returned by the
(successfully invoked) handlers for the initial ``Request``
event to a body and assigns it to the ``Response`` object's
@handler("connect", priority=1)
def connect(self, event, host=None, port=None, secure=None):
if not self._transport.connected:
self.fire(connect(host, port, secure), self._transport)
event.stop()
@handler("started", filter=True, target="*")
def _on_started(self, component, mode):
if self._poller is None:
self._poller = Poller().register(self)
self.push(Ready(self), "ready", self.channel)
return True
@handler("ready")
def _on_ready(self, component):
self.fire(_open(), self.channel)