lib/ruboty/slack_rtm/client.rb in ruboty-slack_rtm-2.0.0 vs lib/ruboty/slack_rtm/client.rb in ruboty-slack_rtm-2.1.0
- old
+ new
@@ -19,12 +19,25 @@
block.call(JSON.parse(message.data))
end
end
def main_loop
+ keep_connection
+
loop do
message = @queue.deq
@client.send(message)
+ end
+ end
+
+ private
+
+ def keep_connection
+ Thread.start do
+ loop do
+ sleep(30)
+ @client.send(type: 'ping')
+ end
end
end
end
end
end