Example #1
0
def main():
    sio.connect('https://ishoal.ink/')

    ishoalc.wait_for_switch()
    if ishoalc.should_stop():
        sio.disconnect()
        return

    def on_switch_change():
        pulse()

    threading.Thread(target=ishoalc.on_switch_chg_threadfn,
                     args=(on_switch_change,), name='py_switch_chg').start()

    def periodic_pulse_threadfn():
        while not ishoalc.should_stop():
            ishoalc.sleep(10 * 1000)
            pulse()

    threading.Thread(target=periodic_pulse_threadfn, name='py_pulse').start()

    # Python is dumb that signal handlers must execute on main thread :(
    # if we ishoalc.sleep(-1) then signal handler will never execute
    # wake up every 100ms to check for signals
    while not ishoalc.should_stop():
        ishoalc.sleep(100)

    sio.disconnect()
Example #2
0
def main():
    global loop
    loop = handshake.start_handshaker()

    new_socketio()

    def on_switch_change():
        if g_sio:
            g_sio.disconnect()

    threading.Thread(target=ishoalc.on_switch_chg_threadfn,
                     args=(on_switch_change, ),
                     name='py_switch_chg').start()

    # Python is dumb that signal handlers must execute on main thread :(
    # if we ishoalc.sleep(-1) then signal handler will never execute
    # wake up every 100ms to check for signals
    while not ishoalc.should_stop():
        ishoalc.sleep(100)

    global finalizing
    finalizing = True

    if g_sio:
        g_sio.disconnect()
    loop.call_soon_threadsafe(loop.stop)
Example #3
0
    def on_disconnect():
        for switchip in all_connections:
            ishoalc.delete_connection(switchip)

        global g_sio
        g_sio = None

        all_connections.clear()
        print('Disconnected', file=remotes_log)

        ishoalc.sleep(100)

        if not finalizing:
            new_socketio()
Example #4
0
 def periodic_pulse_threadfn():
     while not ishoalc.should_stop():
         ishoalc.sleep(10 * 1000)
         pulse()