selfsdk 0.0.220 → 0.0.221
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/messaging.rb +10 -14
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69885b3b440a973bc61faf9194f9626ae4e5dda8554ccca8de0855e888c482f7
|
4
|
+
data.tar.gz: 0a2a5f115422cf4a97614a263ca77df02da9e9de16797f598930f506d1c57e65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
47
|
+
if @connected
|
48
|
+
if ![ON_DEMAND_CLOSE_CODE].include? event.code
|
49
|
+
raise StandardError('websocket connection closed') if !@auto_reconnect
|
50
50
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
51
|
+
if !@reconnection_delay.nil?
|
52
|
+
SelfSDK.logger.debug "waiting #{@reconnection_delay} before "
|
53
|
+
sleep @reconnection_delay
|
54
|
+
end
|
55
55
|
|
56
|
-
|
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
|