-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.py
40 lines (30 loc) · 1.2 KB
/
client.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import os
from client_handler import ClientHandler
from constants.input_options import InputOptions
if __name__ == "__main__":
client = ClientHandler()
option = -1
while option != InputOptions.EXIT:
print("---------------------------")
print("Opções\n")
print("{}) Enviar mensagem".format(InputOptions.ECHO))
print("{}) Listar mensagens".format(InputOptions.LIST))
print("{}) Sair".format(InputOptions.EXIT))
print("---------------------------")
try:
option = int(input('Escolha uma opção: '))
if option == InputOptions.ECHO:
os.system('clear')
message = input('Escreva sua mensagem: ')
client.echo(message)
elif option == InputOptions.LIST:
os.system('clear')
messages = client.get_messages()
print('Listando Mensagens: {}'.format(messages))
elif option == InputOptions.EXIT:
os.system('clear')
print('Finalizando...')
else:
print('Selecione uma opção válida')
except ValueError:
print('Selecione uma opção válida')