- Requesting Data: Use the send_request function in your code to send requests to the microservice. The function takes two parameters: 'command', examples being edit_race, edit_background, and edit_class, and 'data', which the the data specific to each command. Example call: import zmq
SERVER_ENDPOINT = "tcp://127.0.0.1:5555"
def send_request(command, data): context = zmq.Context() socket = context.socket(zmq.REQ) socket.connect(SERVER_ENDPOINT)
request = {'command': command, **data}
socket.send_json(request)
response = socket.recv_json()
print("Response:", response)
if name == "main": send_request('edit_race', {'new_race': 'Elf'})