Skip to content
This repository has been archived by the owner on Jun 30, 2022. It is now read-only.

Commit

Permalink
Shut down the robot on XMPP parse errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmycuadra committed May 7, 2015
1 parent e706627 commit 36e585d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/lita/adapters/hipchat/connector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def jid
end

def connect
register_exception_handler
client_connect
load_roster
register_message_callback
Expand Down Expand Up @@ -114,6 +115,12 @@ def client_connect
client.auth(@password)
end

def register_exception_handler
client.on_exception do |error, connection, error_source|
robot.shut_down
end
end

def register_message_callback
Callback.new(robot, roster).private_message(client)
end
Expand Down
6 changes: 6 additions & 0 deletions spec/lita/adapters/hipchat/connector_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
allow(client).to receive(:auth)
allow(client).to receive(:connect)
allow(client).to receive(:send)
allow(client).to receive(:on_exception)
client
end

Expand Down Expand Up @@ -97,6 +98,11 @@
expect(robot).to receive(:mention_name=).with("LitaBot")
subject.connect
end

it "registers an error handler with the XMPP client" do
expect(client).to receive(:on_exception)
subject.connect
end
end

describe "#join" do
Expand Down

0 comments on commit 36e585d

Please sign in to comment.