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

Add frame Connection#UpdateSecret/Ok #18

Merged
merged 1 commit into from
Feb 13, 2024
Merged
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
46 changes: 46 additions & 0 deletions src/amq/protocol/frames.cr
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ module AMQ
when 51_u16 then Connection::CloseOk.from_io(io, bytesize, format)
when 60_u16 then Connection::Blocked.from_io(io, bytesize, format)
when 61_u16 then Connection::Unblocked.from_io(io, bytesize, format)
when 70_u16 then Connection::UpdateSecret.from_io(io, bytesize, format)
when 71_u16 then Connection::UpdateSecretOk.from_io(io, bytesize, format)
else raise Error::NotImplemented.new(channel, class_id, method_id)
end
when 20_u16
Expand Down Expand Up @@ -582,6 +584,50 @@ module AMQ
self.new
end
end

struct UpdateSecret < Connection
METHOD_ID = 70_u16

def method_id : UInt16
METHOD_ID
end

getter reason

def initialize(@secret : String, @reason : String, bytesize = nil)
bytesize ||= 4 + @secret.bytesize + 1 + @reason.bytesize
super(bytesize.to_u32)
end

def to_io(io, format)
wrap(io, format) do
io.write_bytes LongString.new(@secret), format
io.write_bytes ShortString.new(@reason), format
end
end

def self.from_io(io, bytesize, format)
secret = LongString.from_io(io, format)
reason = ShortString.from_io(io, format)
self.new(secret, reason, bytesize)
end
end

struct UpdateSecretOk < Connection
METHOD_ID = 71_u16

def method_id : UInt16
METHOD_ID
end

def to_io(io, format)
wrap(io, format) { }
end

def self.from_io(io, bytesize, format)
self.new
end
end
end

abstract struct Channel < Method
Expand Down
Loading