Beispiel #1
0
def onRecv(conn, data, _):
    if conn in names:
        message = "<{}> {}".format(data["name"], data["message"])
    else:
        if config["password"] is None or config["password"] == data["password"]:
            message = "{} joined".format(data["name"])
            names[conn] = data["name"]
            ips[conn] = server.getClientAddr(conn)
        else:
            server.removeClient(conn)
            return
    eel.newMessage(addTimestamp(addIP(message, conn)))
    server.send(message)
Beispiel #2
0
def onReady():
    eel.setTextColor(config["textcolor"])
    eel.setBackgroundColor(config["backgroundcolor"])
    eel.setLogColor(config["logcolor"])
    loadLogfile()
    try:
        server.start(config["host"], config["port"])
    except:
        eel.newMessage(
            addTimestamp("Unable to start server on {}:{}".format(
                config["host"], config["port"])))
    else:
        eel.newMessage(
            addTimestamp("Server running on {}:{}".format(*server.getAddr())))
Beispiel #3
0
def onReady():
    eel.setTextColor(config["textcolor"])
    eel.setBackgroundColor(config["backgroundcolor"])
    eel.setLogColor(config["logcolor"])
    loadLogfile()
    try:
        client.connect(config["host"], config["port"])
    except ConnectionRefusedError:
        eel.newMessage(
            addTimestamp("Unable to connect to {}:{}".format(
                config["host"], config["port"])))
    else:
        client.send({"name": config["name"], "password": config["password"]})
        eel.newMessage(
            addTimestamp("Connected to {}:{}".format(*client.getServerAddr())))
        eel.enableInput()
        eel.selectInput()
Beispiel #4
0
def onDisconnected():
    eel.newMessage(addTimestamp("Disconnected from server"))
    eel.disableInput()
Beispiel #5
0
def onRecv(message, _):
    eel.newMessage(addTimestamp(message))
Beispiel #6
0
def loadLogfile():
    if config["logfile"] is not None:
        with open(config["logfile"], "r") as f:
            for line in f:
                eel.newMessage(line, False)
Beispiel #7
0
def onDisconnect(conn):
    message = "{} left".format(names[conn])
    eel.newMessage(addTimestamp(addIP(message, conn)))
    server.send(message)
    names.pop(conn)
    ips.pop(conn)