Skip to content

Commit 633c1c6

Browse files
committed
Add a "copy constructor" ish
1 parent 5f8ae55 commit 633c1c6

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/mqtt/protocol/packets/publish.cr

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ module MQTT
99
getter topic, payload, qos, packet_id, remaining_length
1010
getter? dup, retain
1111

12+
def initialize(pub : Publish, topic = pub.topic, qos = pub.qos, payload = pub.payload, packet_id = pub.packet_id, dup = pub.dup?, retain = pub.retain?)
13+
initialize(topic, payload, packet_id, dup, qos, retain)
14+
end
15+
1216
def initialize(@topic : String, @payload : Payload, @packet_id : UInt16?, @dup : Bool, @qos : UInt8, @retain : Bool)
1317
raise ArgumentError.new("QoS must be 0, 1 or 2") if @qos > 2
1418
raise ArgumentError.new("Topic cannot contain wildcard") if @topic.matches?(/[#+]/)

0 commit comments

Comments
 (0)