Skip to content

Commit

Permalink
more intuitive handling of prev existing session when subscribing
Browse files Browse the repository at this point in the history
  • Loading branch information
kickster97 committed Jan 27, 2025
1 parent afc7c57 commit a77960b
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/lavinmq/mqtt/broker.cr
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,8 @@ module LavinMQ
end

def subscribe(client, packet)
unless session = sessions[client.client_id]?
session = sessions.declare(client.client_id, client.@clean_session)
session.client = client
end
session = sessions[client.client_id]? || sessions.declare(client.client_id, client.@clean_session)
session.client = client
qos = Array(MQTT::SubAck::ReturnCode).new(packet.topic_filters.size)
packet.topic_filters.each do |tf|
qos << MQTT::SubAck::ReturnCode.from_int(tf.qos)
Expand Down

0 comments on commit a77960b

Please sign in to comment.