Tried to make this example code:
import asyncdispatch, ws
var wsc = await newWebSocket("ws://ws.ifelse.io")
echo await wsc.receiveStrPacket()
await wsc.send("Hi, how are you?")
echo await wsc.receiveStrPacket()
wsc.close()
got:
nim-1.6.0\\examples\\example1.nim(3, 17) template/generic instantiation of `await` from here nim-1.6.0\\lib\\pure\\asyncmacro.nim(130, 3) Error: 'yield' only allowed in an iterator
hey, you probably know that await transforms to some block of code that contains yield;
you can use await only in a proc that has async pragma.
the possible solution here is using waitfor INSTEAD of await when you're not in an async proc
https://peterme.net/asynchronous-programming-in-nim.html
is a good place to start writing async code in nim