Commit b05120bda8d8828d394f3cdbf23fea0b72e4040b

Authored by Mestari Yousra
1 parent f0358665

grille coté client

Showing 1 changed file with 41 additions and 0 deletions   Show diff stats
grille_client.py 0 → 100644
... ... @@ -0,0 +1,41 @@
  1 +import zmq
  2 +
  3 +context = zmq.Context()
  4 +
  5 +# Socket to talk to server
  6 +
  7 +socket = context.socket(zmq.DEALER)
  8 +socket.connect("tcp://147.250.9.87:5555")
  9 +
  10 +def grille_client(J):
  11 + for i in range(5):
  12 + #verifier que les bateaux sont bien mis
  13 + empty,validation=socket.recv_multipart()
  14 + while validation.decode() != "ok":
  15 + #question de la tete
  16 + empty,reponse=socket.recv_multipart()
  17 + print(reponse.decode())
  18 + #reponse de la tete
  19 + position_avant=input()
  20 + socket.send_multipart([b'',position_avant.encode()])
  21 + empty,reponse=socket.recv_multipart()
  22 + #tete illegale
  23 + if reponse.decode()=="Cette case est deja occupee":
  24 + print(reponse.decode())
  25 + empty,validation=socket.recv_multipart()
  26 + #tete legale
  27 + else:
  28 + #question de la queue
  29 + print(reponse.decode())
  30 + #reponse de la queue
  31 + position_queue=input()
  32 + socket.send_multipart([b'',position_queue.encode()])
  33 + empty,reponse=socket.recv_multipart()
  34 + #queue illegale
  35 + if reponse.decode()=="Cette combinaison n'est pas valable":
  36 + print(reponse.decode())
  37 + empty,validation=socket.recv_multipart()
  38 + #queue legale
  39 + else:
  40 + empty,validation=socket.recv_multipart()
  41 + return
0 42 \ No newline at end of file
... ...