Пример #1
0
def main():
    screen = psp2d.Screen()
    font = psp2d.Font('font.png')
    bgimg = psp2d.Image('background.png')

    screen.blit(bgimg)
    font.drawText(screen, 0, 0, 'Connecting...')
    screen.swap()

    def cb(s):
        screen.blit(bgimg)
        if s >= 0:
            font.drawText(screen, 0, 0, 'State: %d/4' % s)
        else:
            font.drawText(screen, 0, 0, 'Connected. IP: %s' % pspnet.getIP())
        screen.swap()

    pspnet.connectToAPCTL(1, cb)

    a = Acceptor()
    a.create_socket(socket.AF_INET, socket.SOCK_STREAM)
    a.bind(('', 23))
    a.listen(5)

    thr = threading.Thread(target=runloop)
    thr.setDaemon(True)
    thr.start()

    while True:
        pad = psp2d.Controller()
        if pad.circle:
            break
Пример #2
0
def main():
    screen = psp2d.Screen()
    font = psp2d.Font('font.png')
    bgimg = psp2d.Image('background.png')

    screen.blit(bgimg)
    font.drawText(screen, 0, 0, 'Connecting...')
    screen.swap()

    def cb(s):
        screen.blit(bgimg)
        if s >= 0:
            font.drawText(screen, 0, 0, 'State: %d/4' % s)
        else:
            font.drawText(screen, 0, 0, 'Connected. IP: %s' % pspnet.getIP())
        screen.swap()

    pspnet.connectToAPCTL(1, cb)

    a = Acceptor()
    a.create_socket(socket.AF_INET, socket.SOCK_STREAM)
    a.bind(('', 23))
    a.listen(5)

    thr = threading.Thread(target = runloop)
    thr.setDaemon(True)
    thr.start()

    while True:
        pad = psp2d.Controller()
        if pad.circle:
            break
Пример #3
0
def main():
    screen = psp2d.Screen()
    font = psp2d.Font('font.png')
    bgimg = psp2d.Image('background.png')

    screen.blit(bgimg)
    font.drawText(screen, 0, 0, 'Connecting...')
    screen.swap()

    def cb(s):
        screen.blit(bgimg)
        if s >= 0:
            font.drawText(screen, 0, 0, 'State: %d/4' % s)
        else:
            font.drawText(screen, 0, 0, 'Connected. IP: %s' % pspnet.getIP())
        screen.swap()

    pspnet.connectToAPCTL(1, cb)

    srv = MSServer(('', 80), MSHandler)
    thr = threading.Thread(target=srv.serve_forever)
    thr.setDaemon(True)
    thr.start()

    while True:
        pad = psp2d.Controller()
        if pad.circle:
            break

    pspnet.disconnectAPCTL()
Пример #4
0
def main():
    screen = psp2d.Screen()
    font = psp2d.Font('font.png')
    bgimg = psp2d.Image('background.png')

    screen.blit(bgimg)
    font.drawText(screen, 0, 0, 'Connecting...')
    screen.swap()

    def cb(s):
        screen.blit(bgimg)
        if s >= 0:
            font.drawText(screen, 0, 0, 'State: %d/4' % s)
        else:
            font.drawText(screen, 0, 0, 'Connected. IP: %s' % pspnet.getIP())
        screen.swap()

    pspnet.connectToAPCTL(1, cb)

    srv = MSServer(('', 80), MSHandler)
    thr = threading.Thread(target = srv.serve_forever)
    thr.setDaemon(True)
    thr.start()

    while True:
        pad = psp2d.Controller()
        if pad.circle:
            break

    pspnet.disconnectAPCTL()
Пример #5
0
def main():
    pspnet.connectToAPCTL(1, cb)  # rozkmin
    thr = utworz_jakis_watek()  # rozkmin
    global dzialaj
    try:
        sock = MojSocket('192.168.1.12', 2314)
        sock.stworz_klienta()
        sluchacz_thr = utworz_watek_sluchacza(sock)
        nadawacz_thr = utworz_watek_nadawacza(sock)
        sluchacz_thr.join()
        nadawacz_thr.join()
    finally:
        dzialaj = False
        time.sleep(0.1)
        sock.zamknij()
        pspnet.disconnectAPCTL()  # with lock?
Пример #6
0
 def run(self):
     pspnet.connectToAPCTL(1, self.callback, 10)
Пример #7
0
 def run(self):
     pspnet.connectToAPCTL(1, self.callback, 10)