arcs

Amateur Radio Chat Server with a modern interface
git clone git://squid-tech.com/arcs.git
Log | Files | Refs | README

commit 0b145da1a5c1812dca82ee57a91a3eaa243fccb3
parent 1fa353e89eb20c5202acef60c51b47e906e27f61
Author: joshiemoore <jxm5210@g.rit.edu>
Date:   Fri, 20 Dec 2019 02:43:11 -0500

Add very basic ping command

Diffstat:
Marcs.py | 26+++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/arcs.py b/arcs.py @@ -231,6 +231,19 @@ def relay(port, msg): print("TIMEOUT " + k) _USERS.pop(k) +""" +Respond to /commands sent by users. +""" +def handleCommand(port, user, command): + print(user) + if ("/ping" in command): + # keep the user alive + _USERS[user] = (int(time.time()), command) + + # Pong! + if "-r" in command: + sendMessage(port, HOST, user, _PATH, "Pong!") + """ Main server daemon that receives and routes messages. @@ -264,7 +277,10 @@ def serverd(port, textdisplay): # update the user list _USERS[recv[1]] = (int(time.time()), msg) - #\TODO parse /commands + # check if the is a /command + if msg[0] == "/": + handleCommand(port, recv[1], msg) + continue dispmsg = padcall(recv[1]) + ": " + msg @@ -312,6 +328,12 @@ def chatGuiSend(port, entryText): sendMessage(port, MYCALL, HOST, _PATH, entryText.get()) entryText.set("") + +def testing(port): + while True: + time.sleep(10) + sendMessage(port, MYCALL + "-" + str(random.randint(2, 5)), HOST, _PATH, "/ping -r") + def main(): global _SERVER @@ -362,6 +384,8 @@ def main(): # start server daemon threading.Thread(target=serverd, args=[ser, display]).start() + + threading.Thread(target=testing, args=[ser]).start() else: # start client daemon threading.Thread(target=clientd, args=[ser, display]).start()