rage-rb 1.28.0 → 1.28.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/CHANGELOG.md +5 -0
- data/lib/rage/cable/channel.rb +10 -0
- data/lib/rage/cable/protocols/actioncable_v1_json.rb +4 -0
- data/lib/rage/params_parser.rb +3 -3
- data/lib/rage/request.rb +8 -0
- data/lib/rage/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: 73e373fc25e95467aa4a38003efafda30488596a75fb1ad7cd617891a6918962
|
|
4
|
+
data.tar.gz: 4183890376650de1e9133bcbe08ed645e628610629745d20c729e7464cb9ecb3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4ac0ef8e80416b82f0249675ae98eb973df2e419b12f32521c30933105ad17cef790620a8965eec7c810dc67313d6be4d39e10d05bf937483eeea154c6136088
|
|
7
|
+
data.tar.gz: 10b35efd2ba54aabc8eddc446669e945b530f0f7078899b43d45f8450fd2cf9db6ba746c695b4d2386e300a1adc84d98a2b9a0bd2e86e30d8ecf2f1804dd223f
|
data/CHANGELOG.md
CHANGED
data/lib/rage/cable/channel.rb
CHANGED
|
@@ -434,11 +434,16 @@ class Rage::Cable::Channel
|
|
|
434
434
|
#
|
|
435
435
|
# @param stream [String] the name of the stream
|
|
436
436
|
# @raise [ArgumentError] if the stream name is not a String
|
|
437
|
+
# @note Calling {stop_stream_from} in {unsubscribed} is not strictly required, but is important when clients are dynamically subscribing/unsubscribing from channels on a single connection.
|
|
437
438
|
# @example Subscribe to a stream
|
|
438
439
|
# class NotificationsChannel < Rage::Cable::Channel
|
|
439
440
|
# def subscribed
|
|
440
441
|
# stream_from "notifications"
|
|
441
442
|
# end
|
|
443
|
+
#
|
|
444
|
+
# def unsubscribed
|
|
445
|
+
# stop_stream_from "notifications"
|
|
446
|
+
# end
|
|
442
447
|
# end
|
|
443
448
|
# @example Broadcast to the stream
|
|
444
449
|
# Rage::Cable.broadcast("notifications", { message: "A new member has joined!" })
|
|
@@ -451,11 +456,16 @@ class Rage::Cable::Channel
|
|
|
451
456
|
#
|
|
452
457
|
# @param streamable [#id, String, Symbol, Numeric, Array] an object that will be used to generate the stream name
|
|
453
458
|
# @raise [ArgumentError] if the streamable object does not satisfy the type requirements
|
|
459
|
+
# @note Calling {stop_stream_for} in {unsubscribed} is not strictly required, but is important when clients are dynamically subscribing/unsubscribing from channels on a single connection.
|
|
454
460
|
# @example Subscribe to a stream
|
|
455
461
|
# class NotificationsChannel < Rage::Cable::Channel
|
|
456
462
|
# def subscribed
|
|
457
463
|
# stream_for current_user
|
|
458
464
|
# end
|
|
465
|
+
#
|
|
466
|
+
# def unsubscribed
|
|
467
|
+
# stop_stream_for current_user
|
|
468
|
+
# end
|
|
459
469
|
# end
|
|
460
470
|
# @example Broadcast to the stream
|
|
461
471
|
# NotificationsChannel.broadcast_to(current_user, { message: "You have a new notification!" })
|
|
@@ -49,6 +49,7 @@ class Rage::Cable::Protocols::ActioncableV1Json < Rage::Cable::Protocols::Base
|
|
|
49
49
|
|
|
50
50
|
module COMMAND
|
|
51
51
|
SUBSCRIBE = "subscribe"
|
|
52
|
+
UNSUBSCRIBE = "unsubscribe"
|
|
52
53
|
MESSAGE = "message"
|
|
53
54
|
end
|
|
54
55
|
|
|
@@ -121,6 +122,9 @@ class Rage::Cable::Protocols::ActioncableV1Json < Rage::Cable::Protocols::Base
|
|
|
121
122
|
connection.write(MESSAGES::INVALID)
|
|
122
123
|
end
|
|
123
124
|
|
|
125
|
+
return
|
|
126
|
+
elsif command == COMMAND::UNSUBSCRIBE
|
|
127
|
+
@router.process_disconnection(connection)
|
|
124
128
|
return
|
|
125
129
|
end
|
|
126
130
|
|
data/lib/rage/params_parser.rb
CHANGED
|
@@ -13,11 +13,11 @@ class Rage::ParamsParser
|
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
request_params = if content_type
|
|
16
|
+
request_params = if content_type&.start_with?("application/json")
|
|
17
17
|
json_parse(env["rack.input"].tap { |io| io.rewind }.read)
|
|
18
|
-
elsif content_type
|
|
18
|
+
elsif content_type&.start_with?("application/x-www-form-urlencoded") || content_type.nil?
|
|
19
19
|
Iodine::Rack::Utils.parse_urlencoded_nested_query(env["rack.input"].tap { |io| io.rewind }.read)
|
|
20
|
-
elsif content_type
|
|
20
|
+
elsif content_type&.start_with?("multipart/form-data")
|
|
21
21
|
Iodine::Rack::Utils.parse_multipart(env["rack.input"], content_type)
|
|
22
22
|
end
|
|
23
23
|
|
data/lib/rage/request.rb
CHANGED
|
@@ -223,6 +223,14 @@ class Rage::Request
|
|
|
223
223
|
end
|
|
224
224
|
end
|
|
225
225
|
|
|
226
|
+
# Get the request body stream.
|
|
227
|
+
# @return [IO] the request body stream
|
|
228
|
+
# @example
|
|
229
|
+
# request.body.read # => '{"name":"Rage"}'
|
|
230
|
+
def body
|
|
231
|
+
@env["rack.input"].tap(&:rewind)
|
|
232
|
+
end
|
|
233
|
+
|
|
226
234
|
private
|
|
227
235
|
|
|
228
236
|
def rack_request
|
data/lib/rage/version.rb
CHANGED