-
Notifications
You must be signed in to change notification settings - Fork 0
/
client_side.py
32 lines (22 loc) · 1.05 KB
/
client_side.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
import zmq
class client_side:
def __init__(self, ip_port):
self.context = zmq.Context()
self.sock_req = self.context.socket(zmq.REQ)
self.send_info()
def send_info(self):
while True:
buff = input().split()
self.sock_req.connect("tcp://"+ buff[0])
params = {buff[i] : buff[i + 1] for i in range(2, len(buff), 2) }
if "BELONG" in buff:
params['interval'] = params['interval'].split(',')
params['interval'] = ( int ( params['interval'][0][1:]), int(params['interval'][1][:-1] ) )
params['id'] = int(params['id'])
if "FIND_SUCC" in buff:
params['id'] = int(params["id"])
self.sock_req.send_json({"command_name": buff[1], "method_params": params , "procedence_addr": "127.0.0.1:5050"})
info = self.sock_req.recv_json()
print(info)
self.sock_req.disconnect("tcp://"+ buff[0])
client_side("127.0.0.1:5050")