How to include a client chat prompt in a multi-user threaded python chat server?

Viewed 109

I am currently making a multi-user chat room on python.The major issue that I have run in to is that I would like each user to have a chat prompt on their screen so they know when and where they can type in their message. Currently my send function looks like this :

def csend():
    while True:
        m=input('type message here:')
        msg = f'{alias}: {m}'
        cl.send(msg.encode('utf-8'))


sthread = threading.Thread(target=csend)
sthread.start()

This shows a chat prompt however when a chat comes in from another user it is displayed on the line below the chat prompt. Then the user is expected to type their message on the blank line below the new chat. Looks like this :

type message here:hi
myself:hi
type message here:
User2: Hello
#this blank line is where the user must type their message

I would like it to look more like this:

type message here:hi
myself:hi
User2:hello
type message here:
#this blank line is where the user must type their message

any help would be greatly appreciated.

0 Answers
Related