niv / websocket.nim

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

Does closing websocket with a specific code work? #66

Closed krisppurg closed 4 years ago

krisppurg commented 4 years ago

I've been making my own Discord library in Nim, I've been wondering if it is possible to close a websocket with a specific close code? I am aware that you can do that, but when I close the code, it doesn't respond with a close code provided in the procedure.

I want to know if there is a working code or solution to that or not, because I think it is handy.

If not, then the behaviour should be like this:

Close the socket manually (code: 4000 for example), when some error occurs when websocket is closed, find the close data by extractCloseData(), then the extracted code should be the one provided in the close proc (which is 4000 as an example.).

metagn commented 4 years ago

If I understand your situation correctly: The close proc simply sends a message to the server to close, it's the server's decision whether or not it sends the close code you sent back to you. You should probably keep track of the close code you sent in your own code yourself.

krisppurg commented 4 years ago

I see.