niv / websocket.nim

websockets for nim
http://niv.github.io/websocket.nim/docs/0.1.1/websocket.html
Other
101 stars 25 forks source link

use thread local storage for reqPing #22

Closed luked99 closed 6 years ago

luked99 commented 6 years ago

readData() uses the global reqPing, but that's not allowed for an .async. function.

Follow the pattern in the asyncnet example, where the global state becomes thread-local.

Fixes #20.

Araq commented 6 years ago

I don't like this global/threadlocal state but since it's already there and this PR only improves upon it, I'm gonna accept it.

luked99 commented 6 years ago

If there's a better way, I could have a go at putting something together.

Could pass in some state to use - we're already passing in a boolean to say if it's client or server.

Or perhaps there's a way to attach some state to the socket.