I cannot say anything about protobuf, never used it, but your usage of nim's 
async is wrong:

you could waitFor futures, but every waitFor drives its own async poll loop. 
After the waitFor there is no async poll loop any more. waitFor is usefull when 
you want to call async procs from non async code.

What you should do is to create a async proc, and await every async call inside 
it.

Then either waitFor your async proc to finish or asyncCheck your proc and call 
runForever later (to drive your async loop)

eg:
    
    
    proc foo(): Future[void] {.async.} =
        ## do more stuff
        await ws.sendBinary(stream.data)
        ## do more stuff
    
    waitFor foo() ## this drives an async loop, and waits for the foo() to 
finish
    ### or -----------------
    asyncCheck foo() ## this registers the foo() to the async dispatcher (but 
needs a async loop somewhere else)
    # do more stuff
    runForever ## drives async loop
    
    
    Run

Reply via email to