I'm writing a server-client chat with python and I have this problem when using the client: if I recive a message while typing text gets messed up beetween the output lines. I'm using two separate threads, one for sending input text and one for printing messages from the server.
What i get (input: helloworld):
[message]
[message]
<I start to type>
he[message]
llo[message]
worl[message]
d| <I press enter to send message>
-> helloworld
What i would like to get:
[message]
[message]
<I start to type>
[message]
[message]
[message]
helloworld| <I press enter to send message>
-> helloworld
or
[message]
[message]
<I start to type>
helloworld|
[message]
[message]
[message]
<I press enter to send message>
`-> helloworld
`
So new messages get printed above (better) or under the typing line. I tried to refresh messages only after pressing enter to send the message, but i want the chat to be real-time.
Full code (if you are interested): https://github.com/MattSini912/mschat/blob/main/MSCHAT/src/client.py (input line: 216)
Thank you for helping me!