Skip to content

Commit 5c61124

Browse files
committed
Fix: integration tests.
1 parent 1465682 commit 5c61124

File tree

5 files changed

+23
-9
lines changed

5 files changed

+23
-9
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,11 +374,11 @@ See a fully working example in [examples/hi_real_time](examples/hi_real_time/hi.
374374
##### `websocket_ping`
375375
This setting determines how long the socket can be idle before sending a ping message to confirm it's still connected.
376376

377-
It's important to note that if a ping message was sent and no response was received within the amount of time specified in `websocket_ping`; the client will attempt to reestablish it's connection to the message server.
377+
It's important to note that if a ping message was sent and no response was received within the amount of time specified in `websocket_ping` the client will attempt to reestablish it's connection to the message server.
378378

379-
Note that the ping may take between `websocket_ping` and `websocket_ping * 3/2` seconds to actually trigger when there is no activity on the socket. This is because the timer that checks whether to ping is triggered at every `websocket_ping / 2` interval (see [#289](https://github.com/slack-ruby/slack-ruby-client/pull/289) for further explanation).
379+
Note that the ping may take between `websocket_ping` and `websocket_ping * 3/2` seconds to actually trigger when there is no activity on the socket. This is because the timer that checks whether to ping is triggered at every `websocket_ping / 2` interval.
380380

381-
To disable this feature; set `websocket_ping` to 0.
381+
To disable this feature set `websocket_ping` to 0.
382382

383383
### Connection Methods
384384

lib/slack/real_time/client.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ def run_ping?
139139
!websocket_ping.nil? && websocket_ping > 0
140140
end
141141

142+
def websocket_ping_timer
143+
websocket_ping / 2
144+
end
145+
142146
def to_s
143147
if store && store.team
144148
"id=#{store.team.id}, name=#{store.team.name}, domain=#{store.team.domain}"

lib/slack/real_time/config.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ def concurrency
3333
(val = @concurrency).respond_to?(:call) ? val.call : val
3434
end
3535

36-
def websocket_ping_timer
37-
websocket_ping / 2
38-
end
39-
4036
private
4137

4238
def detect_concurrency

spec/integration/integration_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def wait_for_server
123123

124124
context 'with websocket_ping set' do
125125
before do
126-
client.websocket_ping = 1
126+
client.websocket_ping = 5
127127
end
128128

129129
it 'sends pings' do
@@ -136,7 +136,7 @@ def wait_for_server
136136

137137
start_server
138138

139-
queue.pop_with_timeout(5)
139+
queue.pop_with_timeout(10)
140140
expect(@reply_to).to be 1
141141
end
142142

spec/slack/real_time/client_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,20 @@
4242
end
4343
end
4444
end
45+
context 'websocket_ping_timer' do
46+
context 'with defaults' do
47+
let(:client) { Slack::RealTime::Client.new }
48+
it 'defaults to websocket_ping / 2' do
49+
expect(client.websocket_ping_timer).to eq 15
50+
end
51+
end
52+
context 'with websocket_ping value changed' do
53+
let(:client) { Slack::RealTime::Client.new(websocket_ping: 22) }
54+
it 'defaults to websocket_ping / 2' do
55+
expect(client.websocket_ping_timer).to eq 11
56+
end
57+
end
58+
end
4559
context 'client with a full store', vcr: { cassette_name: 'web/rtm_start', allow_playback_repeats: true } do
4660
let(:client) { Slack::RealTime::Client.new(store_class: Slack::RealTime::Stores::Store) }
4761
let(:url) { 'wss://ms173.slack-msgs.com/websocket/lqcUiAvrKTP-uuid=' }

0 commit comments

Comments
 (0)