Пример #1
0
class FlashlightClient():
    def __init__(self, queue, client=None, port=9999):
        self.queue = queue
        self.stream = None
        self.port = port
        self.ws_client = client
        self.controller = FlashlightController(client)

    @gen.coroutine
    def connect(self):
        self.stream = yield TCPClient().connect('127.0.0.1', self.port)

    @gen.coroutine
    def close_connection(self):
        self.stream.close()

    @gen.coroutine
    def flashlight(self):
        try:
            data = yield self.stream.read_until('\n'.encode())
        except StreamClosedError:
            print("Server closed connection")
            raise gen.Return(False)
        seq = self.controller.get_sequence(data)
        for command in seq:
            self.queue.put((command, self.ws_client))
        ioloop.IOLoop.current().spawn_callback(self.flashlight)
        raise gen.Return(True)
Пример #2
0
class FlashlightClient():

    def __init__(self, queue, client=None, port=9999):
        self.queue = queue
        self.stream = None
        self.port = port
        self.ws_client = client
        self.controller = FlashlightController(client)

    @gen.coroutine
    def connect(self):
        self.stream = yield TCPClient().connect('127.0.0.1', self.port)

    @gen.coroutine
    def close_connection(self):
        self.stream.close()

    @gen.coroutine
    def flashlight(self):
        try:
            data = yield self.stream.read_until('\n'.encode())
        except StreamClosedError:
            print("Server closed connection")
            raise gen.Return(False)
        seq = self.controller.get_sequence(data)
        for command in seq:
            self.queue.put((command, self.ws_client))
        ioloop.IOLoop.current().spawn_callback(self.flashlight)
        raise gen.Return(True)
Пример #3
0
 def __init__(self, queue, client=None, port=9999):
     self.queue = queue
     self.stream = None
     self.port = port
     self.ws_client = client
     self.controller = FlashlightController(client)
Пример #4
0
 def __init__(self, queue, client=None, port=9999):
     self.queue = queue
     self.stream = None
     self.port = port
     self.ws_client = client
     self.controller = FlashlightController(client)