File tree 2 files changed +14
-0
lines changed
2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -266,6 +266,10 @@ def connect(clientid = nil)
266
266
# Receive response
267
267
receive_connack
268
268
269
+ # Reset ping stopwatch
270
+ @last_ping_request = Time . now
271
+ @last_ping_response = Time . now
272
+
269
273
# Start packet reading thread
270
274
@read_thread = Thread . new ( Thread . current ) do |parent |
271
275
Thread . current [ :parent ] = parent
Original file line number Diff line number Diff line change 284
284
client . connect ( 'myclient' )
285
285
end
286
286
287
+ it "should reset @last_ping_request and @last_ping_response" do
288
+ frozen_time = Time . now
289
+ expect ( Time ) . to receive ( :now ) . exactly ( 2 ) . and_return ( frozen_time )
290
+ client . instance_variable_set ( '@last_ping_request' , Time . at ( 0 ) )
291
+ client . instance_variable_set ( '@last_ping_response' , Time . at ( 0 ) )
292
+ client . connect ( 'myclient' )
293
+ expect ( client . instance_variable_get ( '@last_ping_request' ) ) . to eq ( frozen_time )
294
+ expect ( client . instance_variable_get ( '@last_ping_response' ) ) . to eq ( frozen_time )
295
+ end
296
+
287
297
context "protocol version 3.1.0" do
288
298
it "should write a valid CONNECT packet to the socket if not connected" do
289
299
client . version = '3.1.0'
You can’t perform that action at this time.
0 commit comments