realtimex 2.0.2 → 2.0.3
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 +16 -11
- 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: f21f973f93c22c74421369fbde68aa7bf4808226b5bf70a1a03dc0cfd6223629
|
|
4
|
+
data.tar.gz: f72a471ab8e0dff316a742a821ef510ad93c773242a000bbee045a2fac0e245f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 130d5d467d7de0a9eff9c944335a8314eeccd7a14ca9b7b85a9da8b68404cbec9ad59daa80fef95f172a7acd494a85bd27d446220bc81cc8fa1a74c7b40e07d5
|
|
7
|
+
data.tar.gz: 2f9c25e37ab9091175a11977dabf699dbba33cf6f1783e6509ba25c23a4f5f5add34820ba4871a14d0a938e199fd9cf010edbc1379e7df7c73cd4a1ac2096506
|
data/lib/realtimex/connection.rb
CHANGED
|
@@ -26,27 +26,28 @@ class RealtimeX::Connection
|
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
def setup_handlers
|
|
29
|
+
connection = self # Сохраняем ссылку на self
|
|
30
|
+
|
|
29
31
|
@socket.on :open do
|
|
30
|
-
|
|
31
|
-
puts "[RealtimeX] WebSocket connected successfully" if
|
|
32
|
-
emit('connected')
|
|
32
|
+
connection.instance_variable_set(:@connected, true)
|
|
33
|
+
puts "[RealtimeX] WebSocket connected successfully" if connection.instance_variable_get(:@debug)
|
|
34
|
+
connection.emit('connected')
|
|
33
35
|
end
|
|
34
36
|
|
|
35
37
|
@socket.on :close do
|
|
36
|
-
|
|
37
|
-
puts "[RealtimeX] WebSocket disconnected" if
|
|
38
|
-
emit('disconnected')
|
|
38
|
+
connection.instance_variable_set(:@connected, false)
|
|
39
|
+
puts "[RealtimeX] WebSocket disconnected" if connection.instance_variable_get(:@debug)
|
|
40
|
+
connection.emit('disconnected')
|
|
39
41
|
end
|
|
40
42
|
|
|
41
43
|
@socket.on :error do |error|
|
|
42
|
-
puts "[RealtimeX] WebSocket error: #{error}" if
|
|
43
|
-
|
|
44
|
-
@callbacks['error']&.call(error)
|
|
44
|
+
puts "[RealtimeX] WebSocket error: #{error}" if connection.instance_variable_get(:@debug)
|
|
45
|
+
connection.send(:handle_error, error)
|
|
45
46
|
end
|
|
46
47
|
|
|
47
48
|
@socket.on :message do |msg|
|
|
48
|
-
puts "[RealtimeX] Received message: #{msg.data}" if
|
|
49
|
-
handle_message
|
|
49
|
+
puts "[RealtimeX] Received message: #{msg.data}" if connection.instance_variable_get(:@debug)
|
|
50
|
+
connection.send(:handle_message, msg.data)
|
|
50
51
|
end
|
|
51
52
|
end
|
|
52
53
|
|
|
@@ -136,6 +137,10 @@ class RealtimeX::Connection
|
|
|
136
137
|
@connected
|
|
137
138
|
end
|
|
138
139
|
|
|
140
|
+
def handle_error(error)
|
|
141
|
+
@callbacks['error']&.call(error)
|
|
142
|
+
end
|
|
143
|
+
|
|
139
144
|
private
|
|
140
145
|
|
|
141
146
|
def ensure_connected
|
data/lib/realtimex/version.rb
CHANGED