ExpandCollapse

+ 1 wuproxy.flx

  //
  //  Weather proxy device
  //
  open ZMQ;
  
  var context = zmq_init 1;
  
  //  This is where the weather server sits
  var frontend = context.mk_socket ZMQ_SUB;
  frontend.connect "tcp://192.168.55.210:5556";
  
  //  This is our public endpoint for subscribers
  var backend = context.mk_socket ZMQ_PUB;
  backend.bind "tcp://10.1.1.0:8100";
  
  //  Subscribe on everything
  frontend.set_opt$ zmq_subscribe "";
  
  //  Shunt messages out to our own subscribers
  while true do
    var s = frontend.recv_string;
    match frontend.get_opt ZMQ_RCVMORE with
    | zmq_rcvmore b => 
       backend.if b then send_string_part else send_string endif s;
    | _ => assert false;
    endmatch; 
  done