Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Int to Bool conversion compatible with v0.4 #24

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/WebSockets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,17 @@ function send_fragment(ws::WebSocket, islast::Bool, data::Array{Uint8}, opcode=0
b1::Uint8 = (islast ? 0b1000_0000 : 0b0000_0000) | opcode
if l <= 125
write(ws.socket,b1)
write(ws.socket,uint8(l))
write(ws.socket,convert(Uint8,l))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since Uint8 and friends are going away, spelling-wise, my preference is to bite the bullet and add Compat.jl as a dependency (@compat(UInt8(l))). Most packages benefit from using Compat in more than one place/way, so 'bite the bullet' may be a little dramatic. This certainly works as is, though, if you want to use convert for now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hadn't heard about Uint8 and such going away. Can you point me to the
discussion? What's replacing it?

On Thu, Jul 2, 2015 at 5:20 PM, Sean Garborg [email protected]
wrote:

In src/WebSockets.jl
#24 (comment):

@@ -71,17 +71,17 @@ function send_fragment(ws::WebSocket, islast::Bool, data::Array{Uint8}, opcode=0
b1::Uint8 = (islast ? 0b1000_0000 : 0b0000_0000) | opcode
if l <= 125
write(ws.socket,b1)

  • write(ws.socket,uint8(l))
  • write(ws.socket,convert(Uint8,l))

Since Uint8 and friends are going away, spelling-wise, my preference is
to bite the bullet and add Compat.jl as a dependency (@compat(UInt8(l))).
Most packages benefit from using Compat in more than one place/way, so
'bite the bullet' may be a little dramatic. This certainly works as is,
though, if you want to use convert for now.


Reply to this email directly or view it on GitHub
https://github.com/JuliaWeb/WebSockets.jl/pull/24/files#r33788719.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uint types are here for now, until question about type deprecation is resolved, julia-#11200.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UInt8 and friends replaced their lowercase-'i' predecessors in JuliaLang/julia#8907. Looks like JuliaLang/julia#11200 is holding up the deprecation of the lowercase versions.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we use Compat then 0.4 style should be preferable, otherwise looks fine.

write(ws.socket,data)
elseif l <= typemax(Uint16)
write(ws.socket,b1)
write(ws.socket,uint8(126))
write(ws.socket,hton(uint16(l)))
write(ws.socket,convert(Uint8,126))
write(ws.socket,hton(convert(Uint16,l)))
write(ws.socket,data)
elseif l <= typemax(Uint64)
write(ws.socket,b1)
write(ws.socket,uint8(127))
write(ws.socket,hton(uint64(l)))
write(ws.socket,convert(Uint8,127))
write(ws.socket,hton(convert(Uint64,l)))
write(ws.socket,data)
else
error("Attempted to send too much data for one websocket fragment\n")
Expand Down Expand Up @@ -163,12 +163,12 @@ function WebSocketFragment(
,data::Vector{Uint8})

WebSocketFragment(
bool(fin)
, bool(rsv1)
, bool(rsv2)
, bool(rsv3)
fin != 0
, rsv1 != 0
, rsv2 != 0
, rsv3 != 0
, opcode
, bool(masked)
, masked != 0
, payload_len
, maskkey
, data)
Expand Down