ably-pubsub-core 0.0.1.pre → 2.0.0
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/ably/auth.rb +5 -5
- data/lib/ably/exceptions.rb +5 -0
- data/lib/ably/internal.rb +115 -0
- data/lib/ably/logger.rb +3 -3
- data/lib/ably/models/channel_details.rb +1 -1
- data/lib/ably/models/channel_metrics.rb +1 -1
- data/lib/ably/models/channel_occupancy.rb +1 -1
- data/lib/ably/models/channel_state_change.rb +7 -7
- data/lib/ably/models/channel_status.rb +1 -1
- data/lib/ably/models/cipher_params.rb +1 -1
- data/lib/ably/models/connection_details.rb +2 -2
- data/lib/ably/models/connection_state_change.rb +6 -6
- data/lib/ably/models/http_paginated_response.rb +3 -3
- data/lib/ably/models/message.rb +69 -2
- data/lib/ably/models/message_operation.rb +53 -0
- data/lib/ably/models/paginated_result.rb +2 -2
- data/lib/ably/models/presence_message.rb +1 -1
- data/lib/ably/models/protocol_message.rb +14 -1
- data/lib/ably/models/publish_result.rb +32 -0
- data/lib/ably/models/stats.rb +41 -84
- data/lib/ably/models/update_delete_result.rb +32 -0
- data/lib/ably/modules/ably.rb +13 -12
- data/lib/ably/modules/channels_collection.rb +1 -1
- data/lib/ably/modules/http_helpers.rb +11 -11
- data/lib/ably/{rest → pubsub/http}/channel/push_channel.rb +3 -3
- data/lib/ably/pubsub/http/channel.rb +284 -0
- data/lib/ably/pubsub/http/channels.rb +49 -0
- data/lib/ably/pubsub/http/client.rb +738 -0
- data/lib/ably/pubsub/http/middleware/encoder.rb +51 -0
- data/lib/ably/pubsub/http/middleware/exceptions.rb +55 -0
- data/lib/ably/pubsub/http/middleware/external_exceptions.rb +26 -0
- data/lib/ably/pubsub/http/middleware/fail_if_unsupported_mime_type.rb +24 -0
- data/lib/ably/pubsub/http/middleware/logger.rb +60 -0
- data/lib/ably/pubsub/http/middleware/parse_json.rb +29 -0
- data/lib/ably/pubsub/http/middleware/parse_message_pack.rb +45 -0
- data/lib/ably/pubsub/http/presence.rb +117 -0
- data/lib/ably/{rest → pubsub/http}/push/admin.rb +5 -5
- data/lib/ably/{rest → pubsub/http}/push/channel_subscriptions.rb +1 -1
- data/lib/ably/{rest → pubsub/http}/push/device_registrations.rb +1 -1
- data/lib/ably/pubsub/http/push.rb +27 -0
- data/lib/ably/pubsub/http.rb +38 -0
- data/lib/ably/pubsub/realtime/auth.rb +285 -0
- data/lib/ably/{realtime → pubsub/realtime}/channel/channel_manager.rb +2 -2
- data/lib/ably/{realtime → pubsub/realtime}/channel/channel_properties.rb +5 -5
- data/lib/ably/{realtime → pubsub/realtime}/channel/channel_state_machine.rb +2 -2
- data/lib/ably/{realtime → pubsub/realtime}/channel/publisher.rb +9 -4
- data/lib/ably/{realtime → pubsub/realtime}/channel/push_channel.rb +2 -2
- data/lib/ably/pubsub/realtime/channel.rb +545 -0
- data/lib/ably/pubsub/realtime/channels.rb +92 -0
- data/lib/ably/{realtime → pubsub/realtime}/client/incoming_message_dispatcher.rb +43 -8
- data/lib/ably/{realtime → pubsub/realtime}/client/outgoing_message_dispatcher.rb +2 -2
- data/lib/ably/pubsub/realtime/client.rb +372 -0
- data/lib/ably/{realtime → pubsub/realtime}/connection/connection_manager.rb +6 -6
- data/lib/ably/{realtime → pubsub/realtime}/connection/connection_state_machine.rb +2 -2
- data/lib/ably/{realtime → pubsub/realtime}/connection/websocket_transport.rb +1 -1
- data/lib/ably/pubsub/realtime/connection.rb +724 -0
- data/lib/ably/{realtime → pubsub/realtime}/models/nil_channel.rb +3 -3
- data/lib/ably/{realtime → pubsub/realtime}/presence/members_map.rb +2 -2
- data/lib/ably/{realtime → pubsub/realtime}/presence/presence_manager.rb +3 -3
- data/lib/ably/{realtime → pubsub/realtime}/presence/presence_state_machine.rb +2 -2
- data/lib/ably/{realtime → pubsub/realtime}/presence.rb +23 -23
- data/lib/ably/{realtime → pubsub/realtime}/push/admin.rb +8 -8
- data/lib/ably/{realtime → pubsub/realtime}/push/channel_subscriptions.rb +6 -6
- data/lib/ably/{realtime → pubsub/realtime}/push/device_registrations.rb +6 -6
- data/lib/ably/pubsub/realtime/push.rb +27 -0
- data/lib/ably/pubsub/realtime/recovery_key_context.rb +38 -0
- data/lib/ably/pubsub/realtime.rb +58 -0
- data/lib/ably/pubsub.rb +11 -0
- data/lib/ably/version.rb +2 -2
- data/lib/ably.rb +6 -2
- metadata +50 -46
- data/lib/ably/models/stats_types.rb +0 -107
- data/lib/ably/realtime/auth.rb +0 -283
- data/lib/ably/realtime/channel.rb +0 -440
- data/lib/ably/realtime/channels.rb +0 -71
- data/lib/ably/realtime/client.rb +0 -363
- data/lib/ably/realtime/connection.rb +0 -738
- data/lib/ably/realtime/push.rb +0 -25
- data/lib/ably/realtime/recovery_key_context.rb +0 -36
- data/lib/ably/realtime.rb +0 -60
- data/lib/ably/rest/channel.rb +0 -194
- data/lib/ably/rest/channels.rb +0 -47
- data/lib/ably/rest/client.rb +0 -727
- data/lib/ably/rest/middleware/encoder.rb +0 -49
- data/lib/ably/rest/middleware/exceptions.rb +0 -53
- data/lib/ably/rest/middleware/external_exceptions.rb +0 -24
- data/lib/ably/rest/middleware/fail_if_unsupported_mime_type.rb +0 -22
- data/lib/ably/rest/middleware/logger.rb +0 -58
- data/lib/ably/rest/middleware/parse_json.rb +0 -27
- data/lib/ably/rest/middleware/parse_message_pack.rb +0 -43
- data/lib/ably/rest/presence.rb +0 -113
- data/lib/ably/rest/push.rb +0 -25
- data/lib/ably/rest.rb +0 -40
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
module Ably::Realtime::Models
|
|
1
|
+
module Ably::PubSub::Realtime::Models
|
|
2
2
|
# Nil object for Channels, this object is only used within the internal API of this client library
|
|
3
3
|
# @api private
|
|
4
4
|
class NilChannel
|
|
5
5
|
include Ably::Modules::EventEmitter
|
|
6
6
|
extend Ably::Modules::Enum
|
|
7
|
-
STATE = ruby_enum('STATE', Ably::Realtime::Channel::STATE)
|
|
7
|
+
STATE = ruby_enum('STATE', Ably::PubSub::Realtime::Channel::STATE)
|
|
8
8
|
include Ably::Modules::StateEmitter
|
|
9
9
|
include Ably::Modules::UsesStateMachine
|
|
10
10
|
|
|
11
11
|
attr_reader :state_machine
|
|
12
12
|
|
|
13
13
|
def initialize
|
|
14
|
-
@state_machine = Ably::Realtime::Channel::ChannelStateMachine.new(self)
|
|
14
|
+
@state_machine = Ably::PubSub::Realtime::Channel::ChannelStateMachine.new(self)
|
|
15
15
|
@state = STATE(state_machine.current_state)
|
|
16
16
|
end
|
|
17
17
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
module Ably::Realtime
|
|
1
|
+
module Ably::PubSub::Realtime
|
|
2
2
|
class Presence
|
|
3
3
|
# A class encapsulating a map of the members of this presence channel,
|
|
4
4
|
# indexed by the unique {Ably::Models::PresenceMessage#member_key}
|
|
@@ -164,7 +164,7 @@ module Ably::Realtime
|
|
|
164
164
|
channel.emit :update, Ably::Models::ChannelStateChange.new(
|
|
165
165
|
current: channel.state,
|
|
166
166
|
previous: channel.state,
|
|
167
|
-
event: Ably::Realtime::Channel::EVENT(:update),
|
|
167
|
+
event: Ably::PubSub::Realtime::Channel::EVENT(:update),
|
|
168
168
|
reason: re_enter_error,
|
|
169
169
|
resumed: true
|
|
170
170
|
)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
module Ably::Realtime
|
|
1
|
+
module Ably::PubSub::Realtime
|
|
2
2
|
class Presence
|
|
3
3
|
# PresenceManager is responsible for all actions relating to presence state
|
|
4
4
|
#
|
|
@@ -9,8 +9,8 @@ module Ably::Realtime
|
|
|
9
9
|
class PresenceManager
|
|
10
10
|
extend Forwardable
|
|
11
11
|
|
|
12
|
-
# {Ably::Realtime::Presence} this Manager is associated with
|
|
13
|
-
# @return [Ably::Realtime::Presence]
|
|
12
|
+
# {Ably::PubSub::Realtime::Presence} this Manager is associated with
|
|
13
|
+
# @return [Ably::PubSub::Realtime::Presence]
|
|
14
14
|
attr_reader :presence
|
|
15
15
|
|
|
16
16
|
def initialize(presence)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
require 'ably/modules/state_machine'
|
|
2
2
|
|
|
3
|
-
module Ably::Realtime
|
|
3
|
+
module Ably::PubSub::Realtime
|
|
4
4
|
class Presence
|
|
5
|
-
# Internal class to manage presence state for {Ably::Realtime::Presence}
|
|
5
|
+
# Internal class to manage presence state for {Ably::PubSub::Realtime::Presence}
|
|
6
6
|
#
|
|
7
7
|
# @api private
|
|
8
8
|
#
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
module Ably::Realtime
|
|
1
|
+
module Ably::PubSub::Realtime
|
|
2
2
|
# Enables the presence set to be entered and subscribed to, and the historic presence set to be retrieved for a channel.
|
|
3
3
|
#
|
|
4
4
|
class Presence
|
|
@@ -19,8 +19,8 @@ module Ably::Realtime
|
|
|
19
19
|
include Ably::Modules::StateEmitter
|
|
20
20
|
include Ably::Modules::UsesStateMachine
|
|
21
21
|
|
|
22
|
-
# {Ably::Realtime::Channel} this Presence object is associated with
|
|
23
|
-
# @return [Ably::Realtime::Channel]
|
|
22
|
+
# {Ably::PubSub::Realtime::Channel} this Presence object is associated with
|
|
23
|
+
# @return [Ably::PubSub::Realtime::Channel]
|
|
24
24
|
attr_reader :channel
|
|
25
25
|
|
|
26
26
|
# The client_id for the member present on this channel
|
|
@@ -37,7 +37,7 @@ module Ably::Realtime
|
|
|
37
37
|
attr_reader :members
|
|
38
38
|
|
|
39
39
|
# The Presence manager responsible for actions relating to state changes such as entering a channel
|
|
40
|
-
# @return [Ably::Realtime::Presence::PresenceManager]
|
|
40
|
+
# @return [Ably::PubSub::Realtime::Presence::PresenceManager]
|
|
41
41
|
# @api private
|
|
42
42
|
attr_reader :manager
|
|
43
43
|
|
|
@@ -56,7 +56,7 @@ module Ably::Realtime
|
|
|
56
56
|
#
|
|
57
57
|
# @param [String,Hash,nil] data optional data (eg a status message) for this member
|
|
58
58
|
#
|
|
59
|
-
# @yield [Ably::Realtime::Presence] On success, will call the block with this {Ably::Realtime::Presence} object
|
|
59
|
+
# @yield [Ably::PubSub::Realtime::Presence] On success, will call the block with this {Ably::PubSub::Realtime::Presence} object
|
|
60
60
|
# @return [Ably::Util::SafeDeferrable] Deferrable that supports both success (callback) and failure (errback) callbacks
|
|
61
61
|
#
|
|
62
62
|
def enter(data = nil, &success_block)
|
|
@@ -100,7 +100,7 @@ module Ably::Realtime
|
|
|
100
100
|
# @param [String] client_id id of the client
|
|
101
101
|
# @param [String,Hash,nil] data The payload associated with the presence member. A JSON object of arbitrary key-value pairs that may contain metadata, and/or ancillary payloads.
|
|
102
102
|
#
|
|
103
|
-
# @yield [Ably::Realtime::Presence] On success, will call the block with this {Ably::Realtime::Presence} object
|
|
103
|
+
# @yield [Ably::PubSub::Realtime::Presence] On success, will call the block with this {Ably::PubSub::Realtime::Presence} object
|
|
104
104
|
# @return [Ably::Util::SafeDeferrable] Deferrable that supports both success (callback) and failure (errback) callbacks
|
|
105
105
|
#
|
|
106
106
|
def enter_client(client_id, data = nil, &success_block)
|
|
@@ -165,10 +165,10 @@ module Ably::Realtime
|
|
|
165
165
|
#
|
|
166
166
|
# @spec RTP15
|
|
167
167
|
#
|
|
168
|
-
# @param (see {Ably::Realtime::Presence#enter_client})
|
|
168
|
+
# @param (see {Ably::PubSub::Realtime::Presence#enter_client})
|
|
169
169
|
#
|
|
170
|
-
# @yield (see {Ably::Realtime::Presence#enter_client})
|
|
171
|
-
# @return (see {Ably::Realtime::Presence#enter_client})
|
|
170
|
+
# @yield (see {Ably::PubSub::Realtime::Presence#enter_client})
|
|
171
|
+
# @return (see {Ably::PubSub::Realtime::Presence#enter_client})
|
|
172
172
|
#
|
|
173
173
|
def leave_client(client_id, data = nil, &success_block)
|
|
174
174
|
ensure_supported_client_id client_id
|
|
@@ -178,14 +178,14 @@ module Ably::Realtime
|
|
|
178
178
|
end
|
|
179
179
|
|
|
180
180
|
# Updates the data payload for a presence member. If called before entering the presence set, this is treated as
|
|
181
|
-
# an {Ably::Realtime::Presence::STATE.Entered} event. An optional callback may be provided to notify of the success or failure of the operation.
|
|
181
|
+
# an {Ably::PubSub::Realtime::Presence::STATE.Entered} event. An optional callback may be provided to notify of the success or failure of the operation.
|
|
182
182
|
#
|
|
183
183
|
# @spec RTP9
|
|
184
184
|
#
|
|
185
|
-
# @param (see {Ably::Realtime::Presence#enter})
|
|
185
|
+
# @param (see {Ably::PubSub::Realtime::Presence#enter})
|
|
186
186
|
#
|
|
187
|
-
# @yield (see {Ably::Realtime::Presence#enter})
|
|
188
|
-
# @return (see {Ably::Realtime::Presence#enter})
|
|
187
|
+
# @yield (see {Ably::PubSub::Realtime::Presence#enter})
|
|
188
|
+
# @return (see {Ably::PubSub::Realtime::Presence#enter})
|
|
189
189
|
#
|
|
190
190
|
def update(data = nil, &success_block)
|
|
191
191
|
deferrable = create_deferrable
|
|
@@ -233,11 +233,11 @@ module Ably::Realtime
|
|
|
233
233
|
#
|
|
234
234
|
# @spec RTP11, RTP11c1, RTP11c2, RTP11c3
|
|
235
235
|
#
|
|
236
|
-
# @param (see {Ably::Realtime::Presence::MembersMap#get})
|
|
237
|
-
# @option options (see {Ably::Realtime::Presence::MembersMap#get})
|
|
238
|
-
# @yield (see {Ably::Realtime::Presence::MembersMap#get})
|
|
236
|
+
# @param (see {Ably::PubSub::Realtime::Presence::MembersMap#get})
|
|
237
|
+
# @option options (see {Ably::PubSub::Realtime::Presence::MembersMap#get})
|
|
238
|
+
# @yield (see {Ably::PubSub::Realtime::Presence::MembersMap#get})
|
|
239
239
|
#
|
|
240
|
-
# @return (see {Ably::Realtime::Presence::MembersMap#get})
|
|
240
|
+
# @return (see {Ably::PubSub::Realtime::Presence::MembersMap#get})
|
|
241
241
|
#
|
|
242
242
|
def get(options = {}, &block)
|
|
243
243
|
deferrable = create_deferrable
|
|
@@ -271,7 +271,7 @@ module Ably::Realtime
|
|
|
271
271
|
|
|
272
272
|
# Registers a listener that is called each time a {Ably::Models::PresenceMessage} is received on the channel,
|
|
273
273
|
# such as a new member entering the presence set. A callback may optionally be passed in to this call to be notified
|
|
274
|
-
# of success or failure of the channel {Ably::Realtime::Channel#attach} operation.
|
|
274
|
+
# of success or failure of the channel {Ably::PubSub::Realtime::Channel#attach} operation.
|
|
275
275
|
#
|
|
276
276
|
# @spec RTP6a, RTP6b
|
|
277
277
|
#
|
|
@@ -305,8 +305,8 @@ module Ably::Realtime
|
|
|
305
305
|
#
|
|
306
306
|
# @spec RTP12c, RTP12a
|
|
307
307
|
#
|
|
308
|
-
# @param (see {Ably::
|
|
309
|
-
# @option options (see {Ably::
|
|
308
|
+
# @param (see {Ably::PubSub::Http::Presence#history})
|
|
309
|
+
# @option options (see {Ably::PubSub::Http::Presence#history})
|
|
310
310
|
#
|
|
311
311
|
# @yield [Ably::Models::PaginatedResult<Ably::Models::PresenceMessage>] First {Ably::Models::PaginatedResult page} of {Ably::Models::PresenceMessage} objects accessible with {Ably::Models::PaginatedResult#items #items}.
|
|
312
312
|
#
|
|
@@ -497,6 +497,6 @@ module Ably::Realtime
|
|
|
497
497
|
end
|
|
498
498
|
end
|
|
499
499
|
|
|
500
|
-
require 'ably/realtime/presence/presence_manager'
|
|
501
|
-
require 'ably/realtime/presence/members_map'
|
|
502
|
-
require 'ably/realtime/presence/presence_state_machine'
|
|
500
|
+
require 'ably/pubsub/realtime/presence/presence_manager'
|
|
501
|
+
require 'ably/pubsub/realtime/presence/members_map'
|
|
502
|
+
require 'ably/pubsub/realtime/presence/presence_state_machine'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
require 'ably/realtime/push/device_registrations'
|
|
2
|
-
require 'ably/realtime/push/channel_subscriptions'
|
|
1
|
+
require 'ably/pubsub/realtime/push/device_registrations'
|
|
2
|
+
require 'ably/pubsub/realtime/push/channel_subscriptions'
|
|
3
3
|
|
|
4
|
-
module Ably::Realtime
|
|
4
|
+
module Ably::PubSub::Realtime
|
|
5
5
|
class Push
|
|
6
6
|
# Class providing push notification administrative functionality
|
|
7
7
|
# for registering devices and attaching to channels etc.
|
|
@@ -23,7 +23,7 @@ module Ably::Realtime
|
|
|
23
23
|
|
|
24
24
|
# Sends a push notification directly to a device, or a group of devices sharing the same clientId.
|
|
25
25
|
#
|
|
26
|
-
# (see Ably::
|
|
26
|
+
# (see Ably::PubSub::Http::Push#publish)
|
|
27
27
|
#
|
|
28
28
|
# @spec RSH1a
|
|
29
29
|
#
|
|
@@ -42,21 +42,21 @@ module Ably::Realtime
|
|
|
42
42
|
end
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
-
# A {Ably::Realtime::Push::DeviceRegistrations} object.
|
|
45
|
+
# A {Ably::PubSub::Realtime::Push::DeviceRegistrations} object.
|
|
46
46
|
#
|
|
47
47
|
# @spec RSH1b
|
|
48
48
|
#
|
|
49
|
-
# @return [Ably::Realtime::Push::DeviceRegistrations]
|
|
49
|
+
# @return [Ably::PubSub::Realtime::Push::DeviceRegistrations]
|
|
50
50
|
#
|
|
51
51
|
def device_registrations
|
|
52
52
|
@device_registrations ||= DeviceRegistrations.new(self)
|
|
53
53
|
end
|
|
54
54
|
|
|
55
|
-
# A {Ably::Realtime::Push::ChannelSubscriptions} object.
|
|
55
|
+
# A {Ably::PubSub::Realtime::Push::ChannelSubscriptions} object.
|
|
56
56
|
#
|
|
57
57
|
# @spec RSH1c
|
|
58
58
|
#
|
|
59
|
-
# @return [Ably::Realtime::Push::ChannelSubscriptions]
|
|
59
|
+
# @return [Ably::PubSub::Realtime::Push::ChannelSubscriptions]
|
|
60
60
|
#
|
|
61
61
|
def channel_subscriptions
|
|
62
62
|
@channel_subscriptions ||= ChannelSubscriptions.new(self)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
module Ably::Realtime
|
|
1
|
+
module Ably::PubSub::Realtime
|
|
2
2
|
class Push
|
|
3
3
|
# Manage push notification channel subscriptions for devices or clients
|
|
4
4
|
class ChannelSubscriptions
|
|
@@ -16,7 +16,7 @@ module Ably::Realtime
|
|
|
16
16
|
@client = admin.client
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
-
# (see Ably::
|
|
19
|
+
# (see Ably::PubSub::Http::Push::ChannelSubscriptions#list)
|
|
20
20
|
#
|
|
21
21
|
# @yield Block is invoked when request succeeds
|
|
22
22
|
# @return [Ably::Util::SafeDeferrable]
|
|
@@ -33,7 +33,7 @@ module Ably::Realtime
|
|
|
33
33
|
end
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
-
# (see Ably::
|
|
36
|
+
# (see Ably::PubSub::Http::Push::ChannelSubscriptions#list_channels)
|
|
37
37
|
#
|
|
38
38
|
# @yield Block is invoked when request succeeds
|
|
39
39
|
# @return [Ably::Util::SafeDeferrable]
|
|
@@ -47,7 +47,7 @@ module Ably::Realtime
|
|
|
47
47
|
end
|
|
48
48
|
end
|
|
49
49
|
|
|
50
|
-
# (see Ably::
|
|
50
|
+
# (see Ably::PubSub::Http::Push::ChannelSubscriptions#save)
|
|
51
51
|
#
|
|
52
52
|
# @yield Block is invoked when request succeeds
|
|
53
53
|
# @return [Ably::Util::SafeDeferrable]
|
|
@@ -61,7 +61,7 @@ module Ably::Realtime
|
|
|
61
61
|
end
|
|
62
62
|
end
|
|
63
63
|
|
|
64
|
-
# (see Ably::
|
|
64
|
+
# (see Ably::PubSub::Http::Push::ChannelSubscriptions#remove)
|
|
65
65
|
#
|
|
66
66
|
# @yield Block is invoked when request succeeds
|
|
67
67
|
# @return [Ably::Util::SafeDeferrable]
|
|
@@ -78,7 +78,7 @@ module Ably::Realtime
|
|
|
78
78
|
end
|
|
79
79
|
end
|
|
80
80
|
|
|
81
|
-
# (see Ably::
|
|
81
|
+
# (see Ably::PubSub::Http::Push::ChannelSubscriptions#remove_where)
|
|
82
82
|
#
|
|
83
83
|
# @yield Block is invoked when request succeeds
|
|
84
84
|
# @return [Ably::Util::SafeDeferrable]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
module Ably::Realtime
|
|
1
|
+
module Ably::PubSub::Realtime
|
|
2
2
|
class Push
|
|
3
3
|
# Manage device registrations for push notifications
|
|
4
4
|
class DeviceRegistrations
|
|
@@ -16,7 +16,7 @@ module Ably::Realtime
|
|
|
16
16
|
@client = admin.client
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
-
# (see Ably::
|
|
19
|
+
# (see Ably::PubSub::Http::Push::DeviceRegistrations#get)
|
|
20
20
|
#
|
|
21
21
|
# @yield Block is invoked when request succeeds
|
|
22
22
|
# @return [Ably::Util::SafeDeferrable]
|
|
@@ -30,7 +30,7 @@ module Ably::Realtime
|
|
|
30
30
|
end
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
# (see Ably::
|
|
33
|
+
# (see Ably::PubSub::Http::Push::DeviceRegistrations#list)
|
|
34
34
|
#
|
|
35
35
|
# @yield Block is invoked when request succeeds
|
|
36
36
|
# @return [Ably::Util::SafeDeferrable]
|
|
@@ -45,7 +45,7 @@ module Ably::Realtime
|
|
|
45
45
|
end
|
|
46
46
|
end
|
|
47
47
|
|
|
48
|
-
# (see Ably::
|
|
48
|
+
# (see Ably::PubSub::Http::Push::DeviceRegistrations#save)
|
|
49
49
|
#
|
|
50
50
|
# @yield Block is invoked when request succeeds
|
|
51
51
|
# @return [Ably::Util::SafeDeferrable]
|
|
@@ -59,7 +59,7 @@ module Ably::Realtime
|
|
|
59
59
|
end
|
|
60
60
|
end
|
|
61
61
|
|
|
62
|
-
# (see Ably::
|
|
62
|
+
# (see Ably::PubSub::Http::Push::DeviceRegistrations#remove)
|
|
63
63
|
#
|
|
64
64
|
# @yield Block is invoked when request succeeds
|
|
65
65
|
# @return [Ably::Util::SafeDeferrable]
|
|
@@ -73,7 +73,7 @@ module Ably::Realtime
|
|
|
73
73
|
end
|
|
74
74
|
end
|
|
75
75
|
|
|
76
|
-
# (see Ably::
|
|
76
|
+
# (see Ably::PubSub::Http::Push::DeviceRegistrations#remove_where)
|
|
77
77
|
#
|
|
78
78
|
# @yield Block is invoked when request succeeds
|
|
79
79
|
# @return [Ably::Util::SafeDeferrable]
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require 'ably/pubsub/realtime/push/admin'
|
|
2
|
+
|
|
3
|
+
module Ably
|
|
4
|
+
module PubSub
|
|
5
|
+
module Realtime
|
|
6
|
+
# Class providing push notification functionality
|
|
7
|
+
class Push
|
|
8
|
+
# @private
|
|
9
|
+
attr_reader :client
|
|
10
|
+
|
|
11
|
+
def initialize(client)
|
|
12
|
+
@client = client
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# A {Ably::PubSub::Realtime::Push::Admin} object.
|
|
16
|
+
#
|
|
17
|
+
# @spec RSH1
|
|
18
|
+
#
|
|
19
|
+
# @return [Ably::PubSub::Realtime::Push::Admin]
|
|
20
|
+
#
|
|
21
|
+
def admin
|
|
22
|
+
@admin ||= Admin.new(self)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module Ably
|
|
5
|
+
module PubSub
|
|
6
|
+
module Realtime
|
|
7
|
+
class RecoveryKeyContext
|
|
8
|
+
attr_reader :connection_key
|
|
9
|
+
attr_reader :msg_serial
|
|
10
|
+
attr_reader :channel_serials
|
|
11
|
+
|
|
12
|
+
def initialize(connection_key, msg_serial, channel_serials)
|
|
13
|
+
@connection_key = connection_key
|
|
14
|
+
@msg_serial = msg_serial
|
|
15
|
+
@channel_serials = channel_serials
|
|
16
|
+
if @channel_serials.nil?
|
|
17
|
+
@channel_serials = {}
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def to_json
|
|
22
|
+
{ 'connection_key' => @connection_key, 'msg_serial' => @msg_serial, 'channel_serials' => @channel_serials }.to_json
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def self.from_json(obj, logger = nil)
|
|
26
|
+
begin
|
|
27
|
+
data = JSON.load obj
|
|
28
|
+
self.new data['connection_key'], data['msg_serial'], data['channel_serials']
|
|
29
|
+
rescue => e
|
|
30
|
+
logger.warn "unable to decode recovery key, found error #{e}" unless logger.nil?
|
|
31
|
+
return nil
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
require 'eventmachine'
|
|
2
|
+
require 'websocket/driver'
|
|
3
|
+
require 'em-http-request'
|
|
4
|
+
|
|
5
|
+
require 'ably/modules/event_emitter'
|
|
6
|
+
|
|
7
|
+
require 'ably/pubsub/realtime/auth'
|
|
8
|
+
require 'ably/pubsub/realtime/channel'
|
|
9
|
+
require 'ably/pubsub/realtime/channels'
|
|
10
|
+
require 'ably/pubsub/realtime/client'
|
|
11
|
+
require 'ably/pubsub/realtime/connection'
|
|
12
|
+
require 'ably/pubsub/realtime/push'
|
|
13
|
+
require 'ably/pubsub/realtime/presence'
|
|
14
|
+
|
|
15
|
+
require 'ably/models/message_encoders/base'
|
|
16
|
+
|
|
17
|
+
Dir.glob(File.expand_path("../models/*.rb", File.dirname(__FILE__))).each do |file|
|
|
18
|
+
require file
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
Dir.glob(File.expand_path("realtime/models/*.rb", File.dirname(__FILE__))).each do |file|
|
|
22
|
+
require file
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
require 'ably/models/message_encoders/base'
|
|
26
|
+
|
|
27
|
+
require 'ably/pubsub/realtime/client/incoming_message_dispatcher'
|
|
28
|
+
require 'ably/pubsub/realtime/client/outgoing_message_dispatcher'
|
|
29
|
+
|
|
30
|
+
module Ably
|
|
31
|
+
module PubSub
|
|
32
|
+
# Realtime is the namespace of the stateful realtime client and the models it returns.
|
|
33
|
+
#
|
|
34
|
+
# @example
|
|
35
|
+
# client = Ably::PubSub::Server.create_realtime_client("xxxxx")
|
|
36
|
+
# channel = client.channel("test")
|
|
37
|
+
# channel.subscribe do |message|
|
|
38
|
+
# message[:name] #=> "greeting"
|
|
39
|
+
# end
|
|
40
|
+
# channel.publish "greeting", "data"
|
|
41
|
+
#
|
|
42
|
+
module Realtime
|
|
43
|
+
# Refuses construction. This was a convenience alias for the {Ably::PubSub::Realtime::Client}
|
|
44
|
+
# constructor, which no longer accepts direct construction: the package a client is
|
|
45
|
+
# created from is what declares the client's side to the platform, and a client
|
|
46
|
+
# constructed here declares none.
|
|
47
|
+
#
|
|
48
|
+
# Use {Ably::PubSub::Server.create_realtime_client} from the +ably-pubsub-server+ gem.
|
|
49
|
+
#
|
|
50
|
+
# @raise [Ably::Exceptions::DirectConstructionNotSupported] always
|
|
51
|
+
def self.new(*args, **kwargs, &block)
|
|
52
|
+
raise Ably::Internal.direct_construction_error(
|
|
53
|
+
'Ably::PubSub::Realtime.new', 'Ably::PubSub::Server.create_realtime_client(options)'
|
|
54
|
+
)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
data/lib/ably/pubsub.rb
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module Ably
|
|
2
|
+
# The namespace of Ably's Pub/Sub packages. The implementation lives here
|
|
3
|
+
# (+Ably::PubSub::Http+, +Ably::PubSub::Realtime+ and their models), and each per-side
|
|
4
|
+
# package adds its own factory module alongside — +Ably::PubSub::Server+ from the
|
|
5
|
+
# +ably-pubsub-server+ gem.
|
|
6
|
+
#
|
|
7
|
+
# This file only opens the namespace. Files that declare into it with the compact form
|
|
8
|
+
# (+module Ably::PubSub::Http+) need it to exist already, so it is required first.
|
|
9
|
+
module PubSub
|
|
10
|
+
end
|
|
11
|
+
end
|
data/lib/ably/version.rb
CHANGED
data/lib/ably.rb
CHANGED
|
@@ -10,7 +10,11 @@ require 'ably/agent'
|
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
require 'ably/auth'
|
|
13
|
+
require 'ably/pubsub'
|
|
13
14
|
require 'ably/exceptions'
|
|
14
15
|
require 'ably/logger'
|
|
15
|
-
require 'ably/realtime'
|
|
16
|
-
require 'ably/
|
|
16
|
+
require 'ably/pubsub/realtime'
|
|
17
|
+
require 'ably/pubsub/http'
|
|
18
|
+
|
|
19
|
+
# Requires the client classes above: it constructs them.
|
|
20
|
+
require 'ably/internal'
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ably-pubsub-core
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ably
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-10-28 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: eventmachine
|
|
@@ -372,6 +372,7 @@ files:
|
|
|
372
372
|
- lib/ably/agent.rb
|
|
373
373
|
- lib/ably/auth.rb
|
|
374
374
|
- lib/ably/exceptions.rb
|
|
375
|
+
- lib/ably/internal.rb
|
|
375
376
|
- lib/ably/logger.rb
|
|
376
377
|
- lib/ably/models/auth_details.rb
|
|
377
378
|
- lib/ably/models/channel_details.rb
|
|
@@ -395,15 +396,17 @@ files:
|
|
|
395
396
|
- lib/ably/models/message_encoders/cipher.rb
|
|
396
397
|
- lib/ably/models/message_encoders/json.rb
|
|
397
398
|
- lib/ably/models/message_encoders/utf8.rb
|
|
399
|
+
- lib/ably/models/message_operation.rb
|
|
398
400
|
- lib/ably/models/nil_logger.rb
|
|
399
401
|
- lib/ably/models/paginated_result.rb
|
|
400
402
|
- lib/ably/models/presence_message.rb
|
|
401
403
|
- lib/ably/models/protocol_message.rb
|
|
404
|
+
- lib/ably/models/publish_result.rb
|
|
402
405
|
- lib/ably/models/push_channel_subscription.rb
|
|
403
406
|
- lib/ably/models/stats.rb
|
|
404
|
-
- lib/ably/models/stats_types.rb
|
|
405
407
|
- lib/ably/models/token_details.rb
|
|
406
408
|
- lib/ably/models/token_request.rb
|
|
409
|
+
- lib/ably/models/update_delete_result.rb
|
|
407
410
|
- lib/ably/modules/ably.rb
|
|
408
411
|
- lib/ably/modules/async_wrapper.rb
|
|
409
412
|
- lib/ably/modules/channels_collection.rb
|
|
@@ -423,49 +426,50 @@ files:
|
|
|
423
426
|
- lib/ably/modules/state_machine.rb
|
|
424
427
|
- lib/ably/modules/statesman_monkey_patch.rb
|
|
425
428
|
- lib/ably/modules/uses_state_machine.rb
|
|
426
|
-
- lib/ably/
|
|
427
|
-
- lib/ably/
|
|
428
|
-
- lib/ably/
|
|
429
|
-
- lib/ably/
|
|
430
|
-
- lib/ably/
|
|
431
|
-
- lib/ably/
|
|
432
|
-
- lib/ably/
|
|
433
|
-
- lib/ably/
|
|
434
|
-
- lib/ably/
|
|
435
|
-
- lib/ably/
|
|
436
|
-
- lib/ably/
|
|
437
|
-
- lib/ably/
|
|
438
|
-
- lib/ably/
|
|
439
|
-
- lib/ably/
|
|
440
|
-
- lib/ably/
|
|
441
|
-
- lib/ably/
|
|
442
|
-
- lib/ably/
|
|
443
|
-
- lib/ably/
|
|
444
|
-
- lib/ably/realtime
|
|
445
|
-
- lib/ably/realtime/
|
|
446
|
-
- lib/ably/realtime/
|
|
447
|
-
- lib/ably/realtime/
|
|
448
|
-
- lib/ably/realtime/
|
|
449
|
-
- lib/ably/realtime/
|
|
450
|
-
- lib/ably/realtime/
|
|
451
|
-
- lib/ably/realtime/
|
|
452
|
-
- lib/ably/
|
|
453
|
-
- lib/ably/
|
|
454
|
-
- lib/ably/
|
|
455
|
-
- lib/ably/
|
|
456
|
-
- lib/ably/
|
|
457
|
-
- lib/ably/
|
|
458
|
-
- lib/ably/
|
|
459
|
-
- lib/ably/
|
|
460
|
-
- lib/ably/
|
|
461
|
-
- lib/ably/
|
|
462
|
-
- lib/ably/
|
|
463
|
-
- lib/ably/
|
|
464
|
-
- lib/ably/
|
|
465
|
-
- lib/ably/
|
|
466
|
-
- lib/ably/
|
|
467
|
-
- lib/ably/
|
|
468
|
-
- lib/ably/
|
|
429
|
+
- lib/ably/pubsub.rb
|
|
430
|
+
- lib/ably/pubsub/http.rb
|
|
431
|
+
- lib/ably/pubsub/http/channel.rb
|
|
432
|
+
- lib/ably/pubsub/http/channel/push_channel.rb
|
|
433
|
+
- lib/ably/pubsub/http/channels.rb
|
|
434
|
+
- lib/ably/pubsub/http/client.rb
|
|
435
|
+
- lib/ably/pubsub/http/middleware/encoder.rb
|
|
436
|
+
- lib/ably/pubsub/http/middleware/exceptions.rb
|
|
437
|
+
- lib/ably/pubsub/http/middleware/external_exceptions.rb
|
|
438
|
+
- lib/ably/pubsub/http/middleware/fail_if_unsupported_mime_type.rb
|
|
439
|
+
- lib/ably/pubsub/http/middleware/logger.rb
|
|
440
|
+
- lib/ably/pubsub/http/middleware/parse_json.rb
|
|
441
|
+
- lib/ably/pubsub/http/middleware/parse_message_pack.rb
|
|
442
|
+
- lib/ably/pubsub/http/presence.rb
|
|
443
|
+
- lib/ably/pubsub/http/push.rb
|
|
444
|
+
- lib/ably/pubsub/http/push/admin.rb
|
|
445
|
+
- lib/ably/pubsub/http/push/channel_subscriptions.rb
|
|
446
|
+
- lib/ably/pubsub/http/push/device_registrations.rb
|
|
447
|
+
- lib/ably/pubsub/realtime.rb
|
|
448
|
+
- lib/ably/pubsub/realtime/auth.rb
|
|
449
|
+
- lib/ably/pubsub/realtime/channel.rb
|
|
450
|
+
- lib/ably/pubsub/realtime/channel/channel_manager.rb
|
|
451
|
+
- lib/ably/pubsub/realtime/channel/channel_properties.rb
|
|
452
|
+
- lib/ably/pubsub/realtime/channel/channel_state_machine.rb
|
|
453
|
+
- lib/ably/pubsub/realtime/channel/publisher.rb
|
|
454
|
+
- lib/ably/pubsub/realtime/channel/push_channel.rb
|
|
455
|
+
- lib/ably/pubsub/realtime/channels.rb
|
|
456
|
+
- lib/ably/pubsub/realtime/client.rb
|
|
457
|
+
- lib/ably/pubsub/realtime/client/incoming_message_dispatcher.rb
|
|
458
|
+
- lib/ably/pubsub/realtime/client/outgoing_message_dispatcher.rb
|
|
459
|
+
- lib/ably/pubsub/realtime/connection.rb
|
|
460
|
+
- lib/ably/pubsub/realtime/connection/connection_manager.rb
|
|
461
|
+
- lib/ably/pubsub/realtime/connection/connection_state_machine.rb
|
|
462
|
+
- lib/ably/pubsub/realtime/connection/websocket_transport.rb
|
|
463
|
+
- lib/ably/pubsub/realtime/models/nil_channel.rb
|
|
464
|
+
- lib/ably/pubsub/realtime/presence.rb
|
|
465
|
+
- lib/ably/pubsub/realtime/presence/members_map.rb
|
|
466
|
+
- lib/ably/pubsub/realtime/presence/presence_manager.rb
|
|
467
|
+
- lib/ably/pubsub/realtime/presence/presence_state_machine.rb
|
|
468
|
+
- lib/ably/pubsub/realtime/push.rb
|
|
469
|
+
- lib/ably/pubsub/realtime/push/admin.rb
|
|
470
|
+
- lib/ably/pubsub/realtime/push/channel_subscriptions.rb
|
|
471
|
+
- lib/ably/pubsub/realtime/push/device_registrations.rb
|
|
472
|
+
- lib/ably/pubsub/realtime/recovery_key_context.rb
|
|
469
473
|
- lib/ably/util/ably_extensions.rb
|
|
470
474
|
- lib/ably/util/crypto.rb
|
|
471
475
|
- lib/ably/util/pub_sub.rb
|