-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Overhaul websockets code #843
Conversation
Codecov Report
@@ Coverage Diff @@
## master #843 +/- ##
==========================================
- Coverage 80.41% 77.71% -2.71%
==========================================
Files 35 35
Lines 2635 2755 +120
==========================================
+ Hits 2119 2141 +22
- Misses 516 614 +98
📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more |
Sigh......it's proving difficult to get the CI to run the autobahn testsuite here. |
Ok, this is looking better; we're able to run the autobahn test suite for 64-bit linux & macOS. 32-bit python seems not possible. and windows doesn't seem possible because it requires python 2.7 and the windows "compiler tools" isn't supported for 2.7 any more. Going to add docs here and then I think it's ready to merge. |
Did this PR already find bugs? 🚀 |
Oh yes, there were PLENTY of bugs in the old implementation. |
Alright, lots of inline docs added. I think this is ready to go. Again, merging semi-quickly because I have other work coming in, but I would love anyone to look/review things and we can address things in follow up PRs. I plan to review the ~30 open websockets-related issues, which I believe can mostly be closed from the updates here (but we still need to review each to make sure!). |
I love this ♥. Looking at the inline docs and tests, the blocking Can't wait for this to be released! |
Big update to websockets code. The work here includes:
WebSocket
doesn't subtype IO anymore; it's kind of an IO, but also not really in a lot of ways, and it actually makes it a little awkward because of all the ways it isn't an IO, while not really getting any advantage from the subtypingWebSocket
includessend(ws, msg)
for sending messages,receive(ws)
for receiving non-control messages. pings/pongs are handled automatically. You can also iterate theWebSocket
object, where each iteration will yield the body of a non-control message, with iteration finishing when the websocket connection is closed. You can send TEXT messages by callingsend(ws, msg::AbstractString)
, BINARY messages by callingsend(ws, msg::AbstractVector{UInt8})
, and fragmented messages of either type by callingsend(ws, iterable)
where the iterable iterates elements of typeAbstractString
orAbstractVector{UInt8}
(must all be one or the other, no intermixing). To close the websocket, you callclose(ws)
. To manually send ping/pong, you callping(ws)
,pong(ws)
.In terms of making/serving websocket connections, those APIs remain the same via
WebSockets.open
/WebSockets.listen
.