Skip to content

Commit

Permalink
Expose state and update_state method
Browse files Browse the repository at this point in the history
  • Loading branch information
bforma committed Sep 12, 2024
1 parent 146f71d commit cc9000a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/s2/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module S2
class Connection
include S2::MessageHandler

attr_reader :sent_messages
attr_reader :state, :sent_messages

on S2::Messages::ReceptionStatus do |message|
if message_sent?(message.subject_message_id)
Expand All @@ -16,8 +16,9 @@ class Connection
def initialize(ws, logger: Rails.logger)
@ws = ws
@logger = logger
@state = :connected
@sent_messages = {}

update_state :connected
end

def receive_message(message_json)
Expand Down Expand Up @@ -64,6 +65,10 @@ def reply(message, status:)
end
end

def update_state(new_state)
@state = new_state
end

def message_sent?(message_id)
@sent_messages.has_key?(message_id)
end
Expand Down

0 comments on commit cc9000a

Please sign in to comment.