-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
42 lines (33 loc) · 924 Bytes
/
test.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
41
42
from old_msg_server.client import Client
import time
from threading import Thread
c1 = Client("tim")
c2 = Client("name")
def update_messages():
"""
updates the local list of messages
:return: None
"""
msgs = []
run = True
while run:
time.sleep(0.1) # update every 1/10 of a second
new_messages = c1.get_messages() # get any new messages from client
msgs.extend(new_messages) # add to local list of messages
for msg in new_messages: # display new messages
print(msg)
if msg == "{quit}":
run = False
break
Thread(target=update_messages).start()
c1.send_message("hello")
time.sleep(5)
c2.send_message("hello")
time.sleep(5)
c1.send_message("whats up")
time.sleep(5)
c2.send_message("Nothing much")
time.sleep(5)
c1.disconnect()
time.sleep(2)
c2.disconnect()