realtimex 2.0.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/realtimex/connection.rb +8 -2
- data/lib/realtimex/version.rb +1 -1
- 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: f61de2147a65d0ce6897de4ef64d53d4922ab65181efb2693e52815db8c4c654
|
|
4
|
+
data.tar.gz: 42678dd92c6aa73f8af6aed6dca8be74839f30f814cc9dc2a646f991494798ba
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 675bb33e988ce2d37fdd9a7a8ee6ab4397b43eef362f1c3245aa00245a3bd737837b0a1fbe136f24b63238802cf43f32c68586033c758507335553104be16812
|
|
7
|
+
data.tar.gz: c75138edd9e9cbf30b688bc361f8c370716fdd669a3b57c521abce709a601e1b33f2e6f294ebb92d79a142f77f9260a6f39bf3819a1037251244aaaeba800018
|
data/lib/realtimex/connection.rb
CHANGED
|
@@ -8,6 +8,7 @@ class RealtimeX::Connection
|
|
|
8
8
|
@callbacks = {}
|
|
9
9
|
@debug = debug
|
|
10
10
|
@connected = false
|
|
11
|
+
@emitting = false
|
|
11
12
|
end
|
|
12
13
|
|
|
13
14
|
def connect
|
|
@@ -19,7 +20,7 @@ class RealtimeX::Connection
|
|
|
19
20
|
puts "[RealtimeX] WebSocket client created successfully" if @debug
|
|
20
21
|
rescue => e
|
|
21
22
|
puts "[RealtimeX] Connection failed: #{e.message}" if @debug
|
|
22
|
-
|
|
23
|
+
@callbacks['error']&.call({ message: e.message, type: 'connection_error' })
|
|
23
24
|
raise e
|
|
24
25
|
end
|
|
25
26
|
end
|
|
@@ -39,7 +40,8 @@ class RealtimeX::Connection
|
|
|
39
40
|
|
|
40
41
|
@socket.on :error do |error|
|
|
41
42
|
puts "[RealtimeX] WebSocket error: #{error}" if @debug
|
|
42
|
-
emit
|
|
43
|
+
# Прямой вызов callback без emit для избежания рекурсии
|
|
44
|
+
@callbacks['error']&.call(error)
|
|
43
45
|
end
|
|
44
46
|
|
|
45
47
|
@socket.on :message do |msg|
|
|
@@ -109,7 +111,11 @@ class RealtimeX::Connection
|
|
|
109
111
|
end
|
|
110
112
|
|
|
111
113
|
def emit(event, data = nil)
|
|
114
|
+
return if @emitting # Защита от рекурсии
|
|
115
|
+
@emitting = true
|
|
112
116
|
@callbacks[event]&.call(data)
|
|
117
|
+
ensure
|
|
118
|
+
@emitting = false
|
|
113
119
|
end
|
|
114
120
|
|
|
115
121
|
def disconnect
|
data/lib/realtimex/version.rb
CHANGED