Example #1
0
    def listen(self, host, port):
        factory = self.loop.create_server(self, host, port)
        self.server = self.loop.run_until_complete(factory)

        Trace.info("listening on {}:{}", host, port)

        self.thread.start()
Example #2
0
    def connect(self, host, port):
        self.remote_host = host
        self.remote_port = port
        Trace.info("connecting to {}:{}", host, port)
        factory = self.loop.create_connection(self, host, port)
        transport, protocol = self.loop.run_until_complete(factory)

        self.thread.start()
Example #3
0
 def _on_connect(self, result, context):
     super(TcpClient, self)._on_connect(result, context)
     if result:
         peername = context.transport.get_extra_info('peername')
         Trace.info("connected to {}:{}", peername[0], peername[1])
     else:
         Trace.error("error connecting to {}:{}", self.remote_host,
                     self.remote_port)
Example #4
0
 def startup():
     """Starts all the flows attached to the hub."""
     Trace.debug("starting up")
     Hub.instance.setup()
     Hub.instance.start_flows()
     TimeFlow.get().reserve_repetition(Hub.heartbeat_event, \
         timedelta(seconds=Config.heartbeat_interval))
     Trace.info("started")
Example #5
0
    def listen(self, host, port):
        self.dispatcher.create_socket(socket.AF_INET, socket.SOCK_STREAM)
        self.dispatcher.bind((host, port))
        self.dispatcher.listen(5)

        Trace.info("listening on {}:{}", host, port)

        self.thread.start()
Example #6
0
 def _on_connect(self, result, context):
     super(TcpClient, self)._on_connect(result, context)
     if result:
         peername = context.socket.getpeername()
         Trace.info("connected to {}:{}", peername[0], peername[1])
         context.peername = peername
     else:
         Trace.error("error connecting to {}:{}", self.remote_host,
                     self.remote_port)
Example #7
0
    def connect(self, host, port):
        self.connecting = True
        self.remote_host = host
        self.remote_port = port
        Trace.info("connecting to {}:{}", host, port)
        self.dispatcher.create_socket(socket.AF_INET, socket.SOCK_STREAM)
        self.dispatcher.connect((host, port))

        self.thread.start()
Example #8
0
    def on_disconnect(self, handle, context):
        Trace.info("{} disconnected {} {}", self.name, handle, context)

        self._on_disconnect(handle, context)

        if handle != 0:
            SessionBasedLink.handle_pool.release(handle)

        LinkSessionDisconnected().setattrs(link_name=self.name,
                                           handle=handle,
                                           context=context).post()
Example #9
0
    def on_connect(self, result, context):
        Trace.info("{} connected {} {}", self.name, result, context)

        if result:
            handle = SessionBasedLink.handle_pool.acquire()
            context.handle = handle

        self._on_connect(result, context)

        LinkSessionConnected().setattrs(link_name=self.name,
                                        result=result,
                                        context=context).post()
Example #10
0
 def _on_disconnect(self, handle, context):
     super(TcpServer, self)._on_disconnect(handle, context)
     peername = context.transport.get_extra_info('peername')
     Trace.info("disconnected from {}:{}", peername[0], peername[1])
Example #11
0
 def _on_connect(self, result, context):
     super(TcpServer, self)._on_connect(result, context)
     if result:
         peername = context.transport.get_extra_info('peername')
         Trace.info("accepted from {}:{}", peername[0], peername[1])
Example #12
0
 def shutdown():
     """Stops all the flows attached to the hub."""
     Trace.debug("shutting down")
     Hub.instance.stop_flows()
     Hub.instance.teardown()
     Trace.info("stopped")
Example #13
0
 def _on_disconnect(self, handle, context):
     super(TcpServer, self)._on_disconnect(handle, context)
     peername = context.peername
     Trace.info("disconnected from {}:{}", peername[0], peername[1])
Example #14
0
 def _on_connect(self, result, context):
     super(TcpServer, self)._on_connect(result, context)
     if result:
         peername = context.socket.getpeername()
         Trace.info("accepted from {}:{}", peername[0], peername[1])
         context.peername = peername