Sadly with the `case` there seem to be issues:

A `proc` that posts a message:
    
    
    proc tenSeconds(){.async.} =
      ## posts time every ten seconds
      while true:
        await post("time", now().utc.format("ddd, d MMM yyyy HH:mm:ss"))
        await sleepAsync(1000) #*10
    
    
    Run

it uses the post proc as in @ynfle 's first post. On the receiving end:
    
    
    proc echoTime(){.async.} =
      ## receives all messages with a topic string that starts with time
      let sub =  await subscribe("echoTime", @["time"])
      while true:
        let (hasContent, msg) = await sub.fs.read
        if hasContent:
          echo msg[]
          #echo msg.strVal
        else:
          poll()
    
    
    Run

This results in:
    
    
    (topic: "time", id: "", msgtype: "p/s", msg: mkString, strVal: "Wed, 18 May 
2022 11:57:55")
    
    
    Run

But when I uncomment the `echo msg.strVal` I get the error:
    
    
    Error: undeclared field: 'strVal' for type psbus_01.Message [type declared 
in [...]\psbus.nim(12, 3)]
    
    
    Run

It seems as something is lost in the broker / futurestream.

Another way out could be using JSON, Protocol Buffers et al? Seem a bit much.

Reply via email to