예제 #1
0
def start_server(host, port, stop_event):
    # Instantiate Telnet server class and listen to host:port
    clients = []

    def on_connect(client):
        clients.append(client)
        client.send("Telnet test server\nlogin: "******"exit\n")
            break
        except Exception:
            time.sleep(0.5)
    return port, t
예제 #2
0
def PykuMUD():
    logger.boot('System booting.')
    start_snapshot = sysutils.ResourceSnapshot()
    logger.boot(start_snapshot.log_data())
    db_system.init_db()
    from db_system import Session
    from option import Option
    session = Session()
    options = session.query(Option).first()
    logger.boot('Using database version %s, created on %s', options.version, options.date_created)
    from pulse import Pulse
    pulse = session.query(Pulse).first()
    server = miniboa.TelnetServer(port=options.port, timeout=0.0)
    logger.boot('PykuMUD ready on port %d', options.port)
    import web
    web.start_web_server()
    done = False
    while not done:
        top_of_loop = time.time()
        server.poll()
        # process input
        pulse.perform_updates()
        time_spent = time.time() - top_of_loop
        nap_time = pulse.width - time_spent
        if nap_time > 0.0:
            time.sleep(nap_time)
        else:
            logger.warn('Exceeded time slice by %.3f seconds!', abs(nap_time))

    logger.critical('System halted.')
예제 #3
0
def runTelnet(address="127.0.0.1", port=7000):
    tn = miniboa.TelnetServer(port=port,
                              address=address,
                              on_connect=on_connect,
                              on_disconnect=on_disconnect)
    while True:
        tn.poll()
        if len(clients) > 0:
            process_clients()
예제 #4
0
 def __init__(self):
     self.server = miniboa.TelnetServer()
     self.server.on_connect = self.onConnect
     self.clients = []
     print "Starting telnet server on port %d" % self.server.port
     pass