Python
0
Вклад в тег
def recv():
while True:
data = sock.recv(1024)
if data:
print('\n' + data.decode('utf-8'))
async def sender():
session = PromptSession()
while True:
try:
with patch_stdout():
message = await session.prompt_async('{}'.format(nickname) + ': ')
string = nickname + ': ' + message
sock.send(string.encode('utf-8'))
except socket.error:
pass
thread_reciev = threading.Thread(target=recv, name="reciev_message")
thread_reciev.start()
asyncio.get_event_loop().run_until_complete(sender())