selfsdk 0.0.220 → 0.0.221

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/messaging.rb +10 -14
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 481bff1c6e87afe4127ac3c04dd8072fb6b13dc90a3dcb89f58b627cc712c8d5
4
- data.tar.gz: 0e6ce89d41189116ab95e5d42550f7fe48c37061521eab08a97243a484ebd9f9
3
+ metadata.gz: 69885b3b440a973bc61faf9194f9626ae4e5dda8554ccca8de0855e888c482f7
4
+ data.tar.gz: 0a2a5f115422cf4a97614a263ca77df02da9e9de16797f598930f506d1c57e65
5
5
  SHA512:
6
- metadata.gz: 4d1da60803edb536f461ea2e7ce05f32ba6a875161dcb9f0fecb000db628e7bc707b26f76c4106df046d7e2085dbf2117200a099ed77df3c85186aee1a8aa27d
7
- data.tar.gz: 3ff4efd4c14b24e02c96a88b9f20c5bee4551c6c10aab06d6bbdf367b8ad51ce59170a8dc6144469dadd8f9048e4815b78e9c3fce909a6638ce78686988a116a
6
+ metadata.gz: d5d1128c2379969284e616c0ceced68c92e0fd864757312b9eb3b541d2cf2bf825549e2f4b46ba0da5862c2bc9e3c322ce20bb94aff9d9e438ad86fb064134af
7
+ data.tar.gz: 2cbaf8e81f5b29dc188be633f07c4662094e85c2a56dddd639111d9371bdcd9a7f60f08ae54c9857e1bd4fab0000e6f0ea108aebda7f6271cbdf4e9c1ad6922e
data/lib/messaging.rb CHANGED
@@ -13,7 +13,6 @@ require_relative 'messages/message'
13
13
  module SelfSDK
14
14
  class WebsocketClient
15
15
  ON_DEMAND_CLOSE_CODE=3999
16
- CONNECTION_SUPERCEDED=1011
17
16
 
18
17
  attr_accessor :ws
19
18
 
@@ -28,11 +27,10 @@ module SelfSDK
28
27
 
29
28
  # Creates a websocket connection and sets up its callbacks.
30
29
  def start
31
- @connected = true
32
-
33
30
  SelfSDK.logger.debug "starting listener"
34
31
  @ws = Faye::WebSocket::Client.new(@url)
35
32
  SelfSDK.logger.debug "initialized"
33
+ @connected = true
36
34
 
37
35
  @ws.on :open do |_event|
38
36
  SelfSDK.logger.debug "websocket connection established"
@@ -46,21 +44,19 @@ module SelfSDK
46
44
  end
47
45
 
48
46
  @ws.on :close do |event|
49
- return if !@connected
47
+ if @connected
48
+ if ![ON_DEMAND_CLOSE_CODE].include? event.code
49
+ raise StandardError('websocket connection closed') if !@auto_reconnect
50
50
 
51
- SelfSDK.logger.debug "connection closed detected : #{event.code} #{event.reason}"
52
-
53
- if not [ON_DEMAND_CLOSE_CODE, CONNECTION_SUPERCEDED].include? event.code
54
- raise StandardError('websocket connection closed') if !@auto_reconnect
51
+ if !@reconnection_delay.nil?
52
+ SelfSDK.logger.debug "waiting #{@reconnection_delay} before "
53
+ sleep @reconnection_delay
54
+ end
55
55
 
56
- if !@reconnection_delay.nil?
57
- SelfSDK.logger.debug "websocket connection closed (#{event.code}) #{event.reason}"
58
- sleep @reconnection_delay
56
+ @reconnection_delay = 3
59
57
  SelfSDK.logger.debug "reconnecting..."
58
+ start
60
59
  end
61
-
62
- @reconnection_delay = 3
63
- start
64
60
  end
65
61
  end
66
62
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: selfsdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.220
4
+ version: 0.0.221
5
5
  platform: ruby
6
6
  authors:
7
7
  - Self Group Ltd.