selfsdk 0.0.219 → 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 +14 -10
- data/lib/source_definition.rb +2 -1
- metadata +4 -4
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,12 +13,12 @@ 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
|
|
20
19
|
def initialize(url, auto_reconnect, authentication_hook, process_message_hook)
|
21
20
|
@url = url
|
21
|
+
@connected = false
|
22
22
|
@reconnection_delay = nil
|
23
23
|
@auto_reconnect = auto_reconnect
|
24
24
|
@authentication_hook = authentication_hook
|
@@ -30,6 +30,7 @@ module SelfSDK
|
|
30
30
|
SelfSDK.logger.debug "starting listener"
|
31
31
|
@ws = Faye::WebSocket::Client.new(@url)
|
32
32
|
SelfSDK.logger.debug "initialized"
|
33
|
+
@connected = true
|
33
34
|
|
34
35
|
@ws.on :open do |_event|
|
35
36
|
SelfSDK.logger.debug "websocket connection established"
|
@@ -37,23 +38,25 @@ module SelfSDK
|
|
37
38
|
end
|
38
39
|
|
39
40
|
@ws.on :message do |event|
|
41
|
+
return if !@connected
|
42
|
+
|
40
43
|
@process_message_hook.call(event)
|
41
44
|
end
|
42
45
|
|
43
46
|
@ws.on :close do |event|
|
44
|
-
|
47
|
+
if @connected
|
48
|
+
if ![ON_DEMAND_CLOSE_CODE].include? event.code
|
49
|
+
raise StandardError('websocket connection closed') if !@auto_reconnect
|
45
50
|
|
46
|
-
|
47
|
-
|
51
|
+
if !@reconnection_delay.nil?
|
52
|
+
SelfSDK.logger.debug "waiting #{@reconnection_delay} before "
|
53
|
+
sleep @reconnection_delay
|
54
|
+
end
|
48
55
|
|
49
|
-
|
50
|
-
SelfSDK.logger.debug "websocket connection closed (#{event.code}) #{event.reason}"
|
51
|
-
sleep @reconnection_delay
|
56
|
+
@reconnection_delay = 3
|
52
57
|
SelfSDK.logger.debug "reconnecting..."
|
58
|
+
start
|
53
59
|
end
|
54
|
-
|
55
|
-
@reconnection_delay = 3
|
56
|
-
start
|
57
60
|
end
|
58
61
|
end
|
59
62
|
end
|
@@ -61,6 +64,7 @@ module SelfSDK
|
|
61
64
|
# Sends a closing message to the websocket client.
|
62
65
|
def close
|
63
66
|
SelfSDK.logger.debug "connection closed by the client"
|
67
|
+
@connected = false
|
64
68
|
@ws.close(ON_DEMAND_CLOSE_CODE, "connection closed by the client")
|
65
69
|
end
|
66
70
|
|
data/lib/source_definition.rb
CHANGED
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.
|
4
|
+
version: 0.0.221
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Self Group Ltd.
|
@@ -422,16 +422,16 @@ require_paths:
|
|
422
422
|
- lib/services
|
423
423
|
required_ruby_version: !ruby/object:Gem::Requirement
|
424
424
|
requirements:
|
425
|
-
- - "
|
425
|
+
- - "~>"
|
426
426
|
- !ruby/object:Gem::Version
|
427
|
-
version: '
|
427
|
+
version: '3'
|
428
428
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
429
429
|
requirements:
|
430
430
|
- - ">="
|
431
431
|
- !ruby/object:Gem::Version
|
432
432
|
version: '0'
|
433
433
|
requirements: []
|
434
|
-
rubygems_version: 3.
|
434
|
+
rubygems_version: 3.3.7
|
435
435
|
signing_key:
|
436
436
|
specification_version: 4
|
437
437
|
summary: joinself sdk
|