serveur.py 1.4 KB
Newer Older
Mestari Yousra's avatar
Mestari Yousra committed
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
43
44
45
46
47
48
import zmq

context = zmq.Context()

#  Socket to talk to server
print("Connecting to hello world server…")
socket = context.socket(zmq.DEALER)
socket.connect("tcp://147.250.9.87:5555")

#  Do 10 requests, waiting each time for a response
while True :    
	jeu=input("Voulez-vous jouer ?:")
	if jeu=="PLAY":
		socket.send_multipart([b'',b"PLAY"])
		empty,reponse=socket.recv_multipart()
		print(reponse.decode())
		JouC=input()
		socket.send_multipart([b'',JouC.encode()])
		empty,reponse=socket.recv_multipart()
		print(reponse.decode())
		nom=input()
		socket.send_multipart([b'',nom.encode()])
		for i in range(5):
			empty,reponse=socket.recv_multipart()
			print(reponse.decode())
			position_avant=input()
			socket.send_multipart([b'',position_avant.encode()])
			empty,reponse=socket.recv_multipart()
			print(reponse.decode())
			position_queue=input()
			socket.send_multipart([b'',position_queue.encode()])
		empty,reponse=socket.recv_multipart()
		print(reponse.decode())
		case=input()
		socket.send_multipart([b'',case.encode()])
		empty,reponse=socket.recv_multipart()
		reponse=reponse.decode()
		print(reponse)
		while reponse=="Touche! Quelle case frapper?":
			case=input()
			socket.send_multipart([b'',case.encode()])
			empty,reponse=socket.recv_multipart()
			print(reponse.decode())
		empty,reponse=socket.recv_multipart()
		print(reponse.decode())
    
    #  Get the reply.
    #message = socket.recv()