Skip to content

Commit

Permalink
fixup! abstract amqp_connection to prepare for multiple protocols
Browse files Browse the repository at this point in the history
  • Loading branch information
kickster97 committed Aug 14, 2024
1 parent 93e3c42 commit a5a4073
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions src/lavinmq/amqp/client.cr
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ module LavinMQ
Log = ::Log.for "AMQP.client"

def initialize(@socket : IO,
@connection_info : ConnectionInfo,
@vhost : VHost,
@user : User,
tune_ok,
start_ok)
@connection_info : ConnectionInfo,
@vhost : VHost,
@user : User,
tune_ok,
start_ok)
@remote_address = @connection_info.src
@local_address = @connection_info.dst

Expand Down Expand Up @@ -244,11 +244,11 @@ module LavinMQ
@log.trace { "Send BodyFrame (pos #{pos}, length #{length})" }
{% end %}
body = case msg
in BytesMessage
AMQP::Frame::BytesBody.new(frame.channel, length, msg.body[pos, length])
in Message
AMQP::Frame::Body.new(frame.channel, length, msg.body_io)
end
in BytesMessage
AMQP::Frame::BytesBody.new(frame.channel, length, msg.body[pos, length])
in Message
AMQP::Frame::Body.new(frame.channel, length, msg.body_io)
end
socket.write_bytes body, ::IO::ByteFormat::NetworkEndian
socket.flush if websocket
@send_oct_count += 8_u64 + body.bytesize
Expand Down
2 changes: 1 addition & 1 deletion src/lavinmq/amqp/connection_factory.cr
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ module LavinMQ
username, password = credentials(start_ok)
user = users[username]?
return user if user && user.password && user.password.not_nil!.verify(password) &&
guest_only_loopback?(remote_address, user)
guest_only_loopback?(remote_address, user)

if user.nil?
Log.warn { "User \"#{username}\" not found" }
Expand Down

0 comments on commit a5a4073

Please sign in to comment.