I'm trying to compile the websockets example. But it fails to compile.
https://github.com/niv/websocket.nim/blob/master/websocket/server.nim
Compiling that example code (after adding a call to server.serve(cb) at the end) it complains with:
Error: type mismatch: got (AsyncHttpServer, proc (req: Request): Future[system.void]{.locks: <unknown>.})
but expected one of:
proc serve(server: AsyncHttpServer; port: Port;
callback: proc (request: Request): Future[void]; address = ""): Future[void]
It seems to be complaining about the .locks:<unknown> attribute.
If I remove the lines that invoke "waitFor" then it compiles, but obviously doesn't work anymore. What am I doing wrong?
Thanks!
For the benefit of anyone who lands here - the global variable needed to be thread-local. Arguably there ought to be a better way of maintaining the not-really-global-state.
Next problem - the code in the client misses out the last "rn" from the initial HTTP GET request, in client.nim, so doesn't actually work. I'll submit a bug fix when I've got it a bit more working.
I have no problem to compile the server example, but i have not change the last line:
waitFor server.serve(Port(8080), cb)
Could it be the reason of your error ?
The server example with newest push is working ok, (that waitFor server.serve(cb, Port 8080) line).
For the client, when you tested with the server example, it worked but not with echo.websocket.org because of empty bytes returned from echo server, which if you look at recv from asyncnet module, it means the connection is severed.
This is interesting question regarding that, https://stackoverflow.com/questions/34701032/am-i-doing-something-wrong-or-does-echo-websocket-org-not-echo-back-empty-paylo