It's a newbie question. I've got a very simple ZeroMQ server, written in Python. It's basically a remote procedure call, string in, string out.
import sys
import time
import zmq
import mutagen
import json
port = "64107"
context = zmq.Context()
responder = context.socket(zmq.REP)
try:
responder.bind(f"tcp://*:{port}")
except:
sys.exit(0)
print(f'running on port {port}')
try:
while True:
# Wait for next request from client
message = responder.recv()
jsn = message.decode('utf8')
rq = json.loads(jsn)
reply = '{"reply": "unknown"}'
if rq['request'] == 'settags':
audio = mutagen.File(rq['file'], easy=True)
if audio:
reply = '{{"reply": "settags", "file": "{}", "tags": {{"tracknumber": "{}"}}}}'
reply = reply.format(rq['file'], rq['tags']['tracknumber'])
for tag, value in rq['tags'].items():
audio[tag] = value
audio.save()
elif rq['request'] == 'serve':
reply = '{"reply": "serve"}'
# Send reply back to client
responder.send_string(reply)
except KeyboardInterrupt as e:
sys.exit(e)
I'd like to access this server from a Dart app. There is no ZeroMQ package for Dart, to my knowledge. Do I have to use JS zmq module? Is it mandatory to use ZeroMQ on the client side too? Maybe one can use Dart native io to communicate with this server?
Sorry, if the question is silly.