anycable-rails 1.3.3 → 1.3.4
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6200d2863868ed23ac3bcc19478e4310bc4097bfff5884eb5c427ef9c41ec6be
|
4
|
+
data.tar.gz: a33f42cd90e362301dc90f5957b77787cec29e28c3aeee9782d3d81c582301f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f89b8b32dca31e58df2ad57f926b6ef7f2619dd5286d630e393cd7e306fd247cba46e4aa1ce76304bb75486ba52127b0d819dae10093e0a835a5e11c9b02ece
|
7
|
+
data.tar.gz: 5fc0c51cb4eb86c5c8bbbbae0c896af8440ec765370ff0c4a69aaa146e3d2465f1b28993f8f213cd7f8d956d684251aecb7eeda8951db14b0dbbc4c035b45507
|
data/CHANGELOG.md
CHANGED
@@ -28,3 +28,63 @@ ActionCable::Connection::Base.prepend(Module.new do
|
|
28
28
|
@request ||= anycable_request_builder.build_rack_request(@env)
|
29
29
|
end
|
30
30
|
end)
|
31
|
+
|
32
|
+
# Backport command callbacks: https://github.com/rails/rails/pull/44696
|
33
|
+
unless ActionCable::Connection::Base.respond_to?(:before_command)
|
34
|
+
ActionCable::Connection::Base.include ActiveSupport::Callbacks
|
35
|
+
ActionCable::Connection::Base.define_callbacks :command
|
36
|
+
ActionCable::Connection::Base.extend(Module.new do
|
37
|
+
def before_command(*methods, &block)
|
38
|
+
set_callback(:command, :before, *methods, &block)
|
39
|
+
end
|
40
|
+
|
41
|
+
def after_command(*methods, &block)
|
42
|
+
set_callback(:command, :after, *methods, &block)
|
43
|
+
end
|
44
|
+
|
45
|
+
def around_command(*methods, &block)
|
46
|
+
set_callback(:command, :around, *methods, &block)
|
47
|
+
end
|
48
|
+
end)
|
49
|
+
|
50
|
+
ActionCable::Connection::Base.prepend(Module.new do
|
51
|
+
def dispatch_websocket_message(websocket_message)
|
52
|
+
return super unless websocket.alive?
|
53
|
+
|
54
|
+
handle_channel_command(decode(websocket_message))
|
55
|
+
end
|
56
|
+
|
57
|
+
def handle_channel_command(payload)
|
58
|
+
run_callbacks :command do
|
59
|
+
subscriptions.execute_command payload
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end)
|
63
|
+
end
|
64
|
+
|
65
|
+
# Trigger autoload
|
66
|
+
test_case_defined = false
|
67
|
+
|
68
|
+
begin
|
69
|
+
ActionCable::Connection::TestCase # rubocop:disable Lint/Void
|
70
|
+
test_case_defined = true
|
71
|
+
rescue NameError
|
72
|
+
end
|
73
|
+
|
74
|
+
# Backport: https://github.com/rails/rails/pull/45445
|
75
|
+
if test_case_defined && !ActionCable::Connection::TestConnection.method_defined?(:transmissions)
|
76
|
+
ActionCable::Connection::TestConnection.prepend(Module.new do
|
77
|
+
attr_reader :transmissions
|
78
|
+
|
79
|
+
def initialize(*)
|
80
|
+
super
|
81
|
+
|
82
|
+
@transmissions = []
|
83
|
+
@subscriptions = ActionCable::Connection::Subscriptions.new(self)
|
84
|
+
end
|
85
|
+
|
86
|
+
def transmit(cable_message)
|
87
|
+
transmissions << cable_message.with_indifferent_access
|
88
|
+
end
|
89
|
+
end)
|
90
|
+
end
|
@@ -110,22 +110,24 @@ module AnyCable
|
|
110
110
|
end
|
111
111
|
|
112
112
|
def handle_channel_command(identifier, command, data)
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
113
|
+
conn.run_callbacks :command do
|
114
|
+
# We cannot use subscriptions#execute_command here,
|
115
|
+
# since we MUST return true of false, depending on the status
|
116
|
+
# of execution
|
117
|
+
channel = conn.subscriptions.fetch(identifier)
|
118
|
+
case command
|
119
|
+
when "subscribe"
|
120
|
+
channel.handle_subscribe
|
121
|
+
!channel.rejected?
|
122
|
+
when "unsubscribe"
|
123
|
+
conn.subscriptions.remove_subscription(channel)
|
124
|
+
true
|
125
|
+
when "message"
|
126
|
+
channel.perform_action ActiveSupport::JSON.decode(data)
|
127
|
+
true
|
128
|
+
else
|
129
|
+
false
|
130
|
+
end
|
129
131
|
end
|
130
132
|
# Support rescue_from
|
131
133
|
# https://github.com/rails/rails/commit/d2571e560c62116f60429c933d0c41a0e249b58b
|
@@ -28,7 +28,7 @@ default: &default
|
|
28
28
|
broadcast_adapter: http
|
29
29
|
<%- end -%>
|
30
30
|
# Use the same channel name for WebSocket server, e.g.:
|
31
|
-
# $ anycable-go --
|
31
|
+
# $ anycable-go --redis_channel="__anycable__"
|
32
32
|
redis_channel: "__anycable__"
|
33
33
|
<%- if redis? -%>
|
34
34
|
# You can use REDIS_URL env var to configure Redis URL.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: anycable-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- palkan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: anycable
|