Beispiel #1
0
def main():
    master_server = master_server_communication.MasterServer()
    listener = LeapVolumeControlSocketServer()
    controller = Leap.Controller()
    controller.add_listener(listener)

    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.bind((tcpAttr.leap_server_attributes['TCP_IP'],
            tcpAttr.leap_server_attributes['TCP_PORT']))
    s.listen(tcpAttr.leap_server_attributes['MAX_QUEUED_CONNECTION'])
    t_accept = threading.Thread(
        target=LeapVolumeControlSocketServer.server_socket_worker,
        args=(
            listener,
            s,
        ))
    t_send = threading.Thread(
        target=LeapVolumeControlSocketServer.send_to_client_worker,
        args=(listener, ))

    try:
        t_accept.start()
        t_send.start()
        t_accept.join()
        t_send.join()
    except KeyboardInterrupt:
        pass
    finally:
        master_server.close_connection()
        s.close()
Beispiel #2
0
    global broadcast_data_direction
    broadcast_data_direction.set_result(data)
    broadcast_data_direction = loop.create_future()


loop = asyncio.get_event_loop()

broadcast_data_direction = loop.create_future()

tcpsocket_send_server = asyncio.start_server(
    send_to_subscribers,
    tcpAttr.middleware_server_attributes['TCP_IP'],
    tcpAttr.middleware_server_attributes['TCP_PORT'],
    loop=loop)

tasks = connect_to_any_direction_output(), \
        tcpsocket_send_server

master_server = master_server_communication.MasterServer()
self_man = master_server.get_self_man()
try:
    tasks = loop.run_until_complete(asyncio.gather(*tasks))
except KeyboardInterrupt:
    pass
finally:
    tcpsocket_send_server.close()
    broadcast_data_direction.cancel()
    asyncio.gather(*asyncio.Task.all_tasks()).cancel()
    loop.call_soon(loop.close)
    master_server.close_connection()