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.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ably/auth.rb +5 -5
  3. data/lib/ably/exceptions.rb +5 -0
  4. data/lib/ably/internal.rb +115 -0
  5. data/lib/ably/logger.rb +3 -3
  6. data/lib/ably/models/channel_details.rb +1 -1
  7. data/lib/ably/models/channel_metrics.rb +1 -1
  8. data/lib/ably/models/channel_occupancy.rb +1 -1
  9. data/lib/ably/models/channel_state_change.rb +7 -7
  10. data/lib/ably/models/channel_status.rb +1 -1
  11. data/lib/ably/models/cipher_params.rb +1 -1
  12. data/lib/ably/models/connection_details.rb +2 -2
  13. data/lib/ably/models/connection_state_change.rb +6 -6
  14. data/lib/ably/models/http_paginated_response.rb +3 -3
  15. data/lib/ably/models/message.rb +69 -2
  16. data/lib/ably/models/message_operation.rb +53 -0
  17. data/lib/ably/models/paginated_result.rb +2 -2
  18. data/lib/ably/models/presence_message.rb +1 -1
  19. data/lib/ably/models/protocol_message.rb +14 -1
  20. data/lib/ably/models/publish_result.rb +32 -0
  21. data/lib/ably/models/stats.rb +41 -84
  22. data/lib/ably/models/update_delete_result.rb +32 -0
  23. data/lib/ably/modules/ably.rb +13 -12
  24. data/lib/ably/modules/channels_collection.rb +1 -1
  25. data/lib/ably/modules/http_helpers.rb +11 -11
  26. data/lib/ably/{rest → pubsub/http}/channel/push_channel.rb +3 -3
  27. data/lib/ably/pubsub/http/channel.rb +284 -0
  28. data/lib/ably/pubsub/http/channels.rb +49 -0
  29. data/lib/ably/pubsub/http/client.rb +738 -0
  30. data/lib/ably/pubsub/http/middleware/encoder.rb +51 -0
  31. data/lib/ably/pubsub/http/middleware/exceptions.rb +55 -0
  32. data/lib/ably/pubsub/http/middleware/external_exceptions.rb +26 -0
  33. data/lib/ably/pubsub/http/middleware/fail_if_unsupported_mime_type.rb +24 -0
  34. data/lib/ably/pubsub/http/middleware/logger.rb +60 -0
  35. data/lib/ably/pubsub/http/middleware/parse_json.rb +29 -0
  36. data/lib/ably/pubsub/http/middleware/parse_message_pack.rb +45 -0
  37. data/lib/ably/pubsub/http/presence.rb +117 -0
  38. data/lib/ably/{rest → pubsub/http}/push/admin.rb +5 -5
  39. data/lib/ably/{rest → pubsub/http}/push/channel_subscriptions.rb +1 -1
  40. data/lib/ably/{rest → pubsub/http}/push/device_registrations.rb +1 -1
  41. data/lib/ably/pubsub/http/push.rb +27 -0
  42. data/lib/ably/pubsub/http.rb +38 -0
  43. data/lib/ably/pubsub/realtime/auth.rb +285 -0
  44. data/lib/ably/{realtime → pubsub/realtime}/channel/channel_manager.rb +2 -2
  45. data/lib/ably/{realtime → pubsub/realtime}/channel/channel_properties.rb +5 -5
  46. data/lib/ably/{realtime → pubsub/realtime}/channel/channel_state_machine.rb +2 -2
  47. data/lib/ably/{realtime → pubsub/realtime}/channel/publisher.rb +9 -4
  48. data/lib/ably/{realtime → pubsub/realtime}/channel/push_channel.rb +2 -2
  49. data/lib/ably/pubsub/realtime/channel.rb +545 -0
  50. data/lib/ably/pubsub/realtime/channels.rb +92 -0
  51. data/lib/ably/{realtime → pubsub/realtime}/client/incoming_message_dispatcher.rb +43 -8
  52. data/lib/ably/{realtime → pubsub/realtime}/client/outgoing_message_dispatcher.rb +2 -2
  53. data/lib/ably/pubsub/realtime/client.rb +372 -0
  54. data/lib/ably/{realtime → pubsub/realtime}/connection/connection_manager.rb +6 -6
  55. data/lib/ably/{realtime → pubsub/realtime}/connection/connection_state_machine.rb +2 -2
  56. data/lib/ably/{realtime → pubsub/realtime}/connection/websocket_transport.rb +1 -1
  57. data/lib/ably/pubsub/realtime/connection.rb +724 -0
  58. data/lib/ably/{realtime → pubsub/realtime}/models/nil_channel.rb +3 -3
  59. data/lib/ably/{realtime → pubsub/realtime}/presence/members_map.rb +2 -2
  60. data/lib/ably/{realtime → pubsub/realtime}/presence/presence_manager.rb +3 -3
  61. data/lib/ably/{realtime → pubsub/realtime}/presence/presence_state_machine.rb +2 -2
  62. data/lib/ably/{realtime → pubsub/realtime}/presence.rb +23 -23
  63. data/lib/ably/{realtime → pubsub/realtime}/push/admin.rb +8 -8
  64. data/lib/ably/{realtime → pubsub/realtime}/push/channel_subscriptions.rb +6 -6
  65. data/lib/ably/{realtime → pubsub/realtime}/push/device_registrations.rb +6 -6
  66. data/lib/ably/pubsub/realtime/push.rb +27 -0
  67. data/lib/ably/pubsub/realtime/recovery_key_context.rb +38 -0
  68. data/lib/ably/pubsub/realtime.rb +58 -0
  69. data/lib/ably/pubsub.rb +11 -0
  70. data/lib/ably/version.rb +2 -2
  71. data/lib/ably.rb +6 -2
  72. metadata +50 -46
  73. data/lib/ably/models/stats_types.rb +0 -107
  74. data/lib/ably/realtime/auth.rb +0 -283
  75. data/lib/ably/realtime/channel.rb +0 -440
  76. data/lib/ably/realtime/channels.rb +0 -71
  77. data/lib/ably/realtime/client.rb +0 -363
  78. data/lib/ably/realtime/connection.rb +0 -738
  79. data/lib/ably/realtime/push.rb +0 -25
  80. data/lib/ably/realtime/recovery_key_context.rb +0 -36
  81. data/lib/ably/realtime.rb +0 -60
  82. data/lib/ably/rest/channel.rb +0 -194
  83. data/lib/ably/rest/channels.rb +0 -47
  84. data/lib/ably/rest/client.rb +0 -727
  85. data/lib/ably/rest/middleware/encoder.rb +0 -49
  86. data/lib/ably/rest/middleware/exceptions.rb +0 -53
  87. data/lib/ably/rest/middleware/external_exceptions.rb +0 -24
  88. data/lib/ably/rest/middleware/fail_if_unsupported_mime_type.rb +0 -22
  89. data/lib/ably/rest/middleware/logger.rb +0 -58
  90. data/lib/ably/rest/middleware/parse_json.rb +0 -27
  91. data/lib/ably/rest/middleware/parse_message_pack.rb +0 -43
  92. data/lib/ably/rest/presence.rb +0 -113
  93. data/lib/ably/rest/push.rb +0 -25
  94. data/lib/ably/rest.rb +0 -40
@@ -0,0 +1,51 @@
1
+ require 'faraday'
2
+ require 'json'
3
+
4
+ module Ably
5
+ module PubSub
6
+ module Http
7
+ module Middleware
8
+ # Encode the body of the message according to the mime type
9
+ class Encoder < Faraday::Middleware
10
+ CONTENT_TYPE = 'Content-Type'.freeze unless defined? CONTENT_TYPE
11
+
12
+ def call(env)
13
+ encode env if env.body
14
+ @app.call env
15
+ end
16
+
17
+ private
18
+ def encode(env)
19
+ env.body = case request_type(env)
20
+ when 'application/x-msgpack'
21
+ to_msgpack(env.body)
22
+ when 'application/json', '', nil
23
+ env.request_headers[CONTENT_TYPE] = 'application/json'
24
+ to_json(env.body)
25
+ else
26
+ env.body
27
+ end
28
+ end
29
+
30
+ def to_msgpack(body)
31
+ body.to_msgpack
32
+ end
33
+
34
+ def to_json(body)
35
+ if body.kind_of?(String)
36
+ body
37
+ else
38
+ body.to_json
39
+ end
40
+ end
41
+
42
+ def request_type(env)
43
+ type = env.request_headers[CONTENT_TYPE].to_s
44
+ type = type.split(';', 2).first if type.index(';')
45
+ type
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,55 @@
1
+ require 'faraday'
2
+ require 'json'
3
+
4
+ module Ably
5
+ module PubSub
6
+ module Http
7
+ module Middleware
8
+ # HTTP exceptions raised by Ably due to an error status code
9
+ # Ably returns JSON/Msgpack error codes and messages so include this if possible in the exception messages
10
+ class Exceptions < Faraday::Middleware
11
+ def on_complete(env)
12
+ if env.status >= 400
13
+ error_status_code = env.status
14
+ error_code = nil
15
+
16
+ if env.body.kind_of?(Hash)
17
+ error = env.body.fetch('error', {})
18
+ error_status_code = error['statusCode'].to_i if error['statusCode']
19
+ error_code = error['code'].to_i if error['code']
20
+
21
+ if error
22
+ message = "#{error['message']} (status: #{error_status_code}, code: #{error_code})"
23
+ else
24
+ message = env.body
25
+ end
26
+ else
27
+ message = env.body
28
+ end
29
+
30
+ message = 'Unknown server error' if message.to_s.strip == ''
31
+ request_id = env.request.context[:request_id] if env.request.context
32
+ exception_args = [message, error_status_code, error_code, nil, { request_id: request_id }]
33
+
34
+ if env.status >= 500
35
+ raise Ably::Exceptions::ServerError.new(*exception_args)
36
+ elsif env.status == 401
37
+ if Ably::Exceptions::TOKEN_EXPIRED_CODE.include?(error_code)
38
+ raise Ably::Exceptions::TokenExpired.new(*exception_args)
39
+ else
40
+ raise Ably::Exceptions::UnauthorizedRequest.new(*exception_args)
41
+ end
42
+ elsif env.status == 403
43
+ raise Ably::Exceptions::ForbiddenRequest.new(*exception_args)
44
+ elsif env.status == 404
45
+ raise Ably::Exceptions::ResourceMissing.new(*exception_args)
46
+ else
47
+ raise Ably::Exceptions::InvalidRequest.new(*exception_args)
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,26 @@
1
+ require 'faraday'
2
+
3
+ module Ably
4
+ module PubSub
5
+ module Http
6
+ module Middleware
7
+ # HTTP exceptions raised due to a status code error on a 3rd party site
8
+ # Used by auth calls
9
+ class ExternalExceptions < Faraday::Middleware
10
+ def on_complete(env)
11
+ if env.status >= 400
12
+ error_status_code = env.status
13
+ message = "Error #{error_status_code}: #{(env.body || '')[0...200]}"
14
+
15
+ if error_status_code >= 500
16
+ raise Ably::Exceptions::ServerError, message
17
+ else
18
+ raise Ably::Exceptions::InvalidRequest, message
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,24 @@
1
+ require 'faraday'
2
+ require 'json'
3
+
4
+ module Ably
5
+ module PubSub
6
+ module Http
7
+ module Middleware
8
+ class FailIfUnsupportedMimeType < Faraday::Middleware
9
+ def on_complete(env)
10
+ unless env.response_headers['Ably-Middleware-Parsed'] == true
11
+ # Ignore empty body with success status code for no body response
12
+ return if env.body.to_s.empty? && env.status == 204
13
+
14
+ unless (500..599).include?(env.status)
15
+ raise Ably::Exceptions::InvalidResponseBody,
16
+ "Content Type #{env.response_headers['Content-Type']} is not supported by this client library"
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,60 @@
1
+ require 'faraday'
2
+
3
+ module Ably
4
+ module PubSub
5
+ module Http
6
+ module Middleware
7
+ class Logger < Faraday::Middleware
8
+ extend Forwardable
9
+
10
+ def initialize(app, logger = nil)
11
+ super(app)
12
+ @logger = logger || begin
13
+ require 'logger'
14
+ ::Logger.new(STDOUT)
15
+ end
16
+ end
17
+
18
+ def_delegators :@logger, :debug, :info, :warn, :error, :fatal
19
+
20
+ def call(env)
21
+ debug { "=> URL: #{env.method} #{env.url}, Headers: #{dump_headers env.request_headers}" }
22
+ debug { "=> Body: #{body_for(env)}" }
23
+ super
24
+ end
25
+
26
+ def on_complete(env)
27
+ debug "<= Status: #{env.status}, Headers: #{dump_headers env.response_headers}"
28
+ debug "<= Body: #{body_for(env)}"
29
+ end
30
+
31
+ private
32
+ def dump_headers(headers)
33
+ headers.map { |k, v| "#{k}: #{v.inspect}" }.join(", ")
34
+ end
35
+
36
+ def body_for(env)
37
+ return '' if !env.body || env.body.empty?
38
+
39
+ if env.request_headers['Content-Type'] == 'application/x-msgpack'
40
+ MessagePack.unpack(env.body)
41
+ else
42
+ env.body
43
+ end
44
+
45
+ rescue StandardError
46
+ readable_body(env.body)
47
+ end
48
+
49
+ def readable_body(body)
50
+ if body.respond_to?(:encoding) && body.encoding == Encoding::ASCII_8BIT
51
+ body.unpack('H*')
52
+ else
53
+ body
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,29 @@
1
+ require 'faraday'
2
+ require 'json'
3
+
4
+ module Ably
5
+ module PubSub
6
+ module Http
7
+ module Middleware
8
+ class ParseJson < Faraday::Middleware
9
+ def on_complete(env)
10
+ if env.response_headers['Content-Type'] == 'application/json'
11
+ env.body = parse(env.body) unless env.response_headers['Ably-Middleware-Parsed'] == true
12
+ env.response_headers['Ably-Middleware-Parsed'] = true
13
+ end
14
+ end
15
+
16
+ def parse(body)
17
+ if body.length > 0
18
+ JSON.parse(body)
19
+ else
20
+ body
21
+ end
22
+ rescue JSON::ParserError => e
23
+ raise Ably::Exceptions::InvalidResponseBody, "Expected JSON response: #{e.message}"
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,45 @@
1
+ require 'faraday'
2
+ require 'msgpack'
3
+
4
+ module Ably
5
+ module PubSub
6
+ module Http
7
+ module Middleware
8
+ class ParseMessagePack < Faraday::Middleware
9
+ def on_complete(env)
10
+ if env.response_headers['Content-Type'] == 'application/x-msgpack'
11
+ env.body = parse(env.body) unless env.response_headers['Ably-Middleware-Parsed'] == true
12
+ env.response_headers['Ably-Middleware-Parsed'] = true
13
+ end
14
+ rescue Ably::Exceptions::InvalidResponseBody => e
15
+ debug_info = {
16
+ method: env.method,
17
+ url: env.url,
18
+ base64_body: base64_body(env.body),
19
+ response_headers: env.response_headers
20
+ }
21
+ raise Ably::Exceptions::InvalidResponseBody, "#{e.message}\nRequest env: #{debug_info}"
22
+ end
23
+
24
+ def parse(body)
25
+ if body.length > 0
26
+ MessagePack.unpack(body)
27
+ else
28
+ body
29
+ end
30
+ rescue MessagePack::UnknownExtTypeError => e
31
+ raise Ably::Exceptions::InvalidResponseBody, "MessagePack::UnknownExtTypeError body could not be decoded: #{e.message}. Got Base64:\n#{base64_body(body)}"
32
+ rescue MessagePack::MalformedFormatError => e
33
+ raise Ably::Exceptions::InvalidResponseBody, "MessagePack::MalformedFormatError body could not be decoded: #{e.message}. Got Base64:\n#{base64_body(body)}"
34
+ end
35
+
36
+ def base64_body(body)
37
+ Base64.encode64(body)
38
+ rescue => err
39
+ "[#{err.message}! Could not base64 encode body: '#{body}']"
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,117 @@
1
+ module Ably
2
+ module PubSub
3
+ module Http
4
+ # Enables the retrieval of the current and historic presence set for a channel.
5
+ #
6
+ class Presence
7
+ include Ably::Modules::Conversions
8
+
9
+ # {Ably::PubSub::Http::Client} for this Presence object
10
+ #
11
+ # @return {Ably::PubSub::Http::Client}
12
+ #
13
+ # @private
14
+ attr_reader :client
15
+
16
+ # {Ably::PubSub::Http::Channel} this Presence object is associated with
17
+ #
18
+ # @return [Ably::PubSub::Http::Channel]
19
+ #
20
+ attr_reader :channel
21
+
22
+ # Initialize a new Presence object
23
+ #
24
+ # @param client [Ably::PubSub::Http::Client]
25
+ # @param channel [Channel] The channel object
26
+ #
27
+ def initialize(client, channel)
28
+ @client = client
29
+ @channel = channel
30
+ end
31
+
32
+ # Retrieves the current members present on the channel and the metadata for each member, such as their
33
+ # {Ably::Models::PresenceMessage::ACTION} and ID. Returns a {Ably::Models::PaginatedResult} object,
34
+ # containing an array of {Ably::Models::PresenceMessage} objects.
35
+ #
36
+ # @spec RSPa, RSP3a, RSP3a2, RSP3a3
37
+ #
38
+ # @param [Hash] options the options for the set of members present
39
+ # @option options [Integer] :limit An upper limit on the number of messages returned. The default is 100, and the maximum is 1000. (RSP3a)
40
+ # @option options [String] :client_id Filters the list of returned presence members by a specific client using its ID. (RSP3a2)
41
+ # @option options [String] :connection_id Filters the list of returned presence members by a specific connection using its ID. (RSP3a3)
42
+ #
43
+ # @return [Ably::Models::PaginatedResult<Ably::Models::PresenceMessage>] A {Ably::Models::PaginatedResult} object containing an array of {Ably::Models::PresenceMessage} objects.
44
+ #
45
+ def get(options = {})
46
+ options = options = {
47
+ :limit => 100
48
+ }.merge(options)
49
+
50
+ paginated_options = {
51
+ coerce_into: 'Ably::Models::PresenceMessage',
52
+ async_blocking_operations: options.delete(:async_blocking_operations),
53
+ }
54
+
55
+ # The REST API names these query params clientId and connectionId (RSP3a2, RSP3a3),
56
+ # so the idiomatic snake_case options have to be converted before they are sent.
57
+ response = client.get(base_path, IdiomaticRubyWrapper(options).as_json)
58
+
59
+ Ably::Models::PaginatedResult.new(response, base_path, client, paginated_options) do |presence_message|
60
+ presence_message.tap do |message|
61
+ decode_message message
62
+ end
63
+ end
64
+ end
65
+
66
+ # Retrieves a {Ably::Models::PaginatedResult} object, containing an array of historical {Ably::Models::PresenceMessage}
67
+ # objects for the channel. If the channel is configured to persist messages, then presence messages can be retrieved
68
+ # from history for up to 72 hours in the past. If not, presence messages can only be retrieved from history for up to two minutes in the past.
69
+ #
70
+ # @spec RSP4a
71
+ #
72
+ # @param [Hash] options the options for the message history request
73
+ # @option options [Integer,Time] :start The time from which messages are retrieved, specified as milliseconds since the Unix epoch. (RSP4b1)
74
+ # @option options [Integer,Time] :end The time until messages are retrieved, specified as milliseconds since the Unix epoch. (RSP4b1)
75
+ # @option options [Symbol] :direction The order for which messages are returned in. Valid values are backwards which orders messages from most recent to oldest, or forwards which orders messages from oldest to most recent. The default is backwards. (RSP4b2)
76
+ # @option options [Integer] :limit An upper limit on the number of messages returned. The default is 100, and the maximum is 1000. (RSP4b3)
77
+ #
78
+ # @return [Ably::Models::PaginatedResult<Ably::Models::PresenceMessage>] A {Ably::Models::PaginatedResult} object containing an array of {Ably::Models::PresenceMessage} objects.
79
+ #
80
+ def history(options = {})
81
+ url = "#{base_path}/history"
82
+ options = options = {
83
+ :direction => :backwards,
84
+ :limit => 100
85
+ }.merge(options)
86
+
87
+ [:start, :end].each { |option| options[option] = as_since_epoch(options[option]) if options.has_key?(option) }
88
+ raise ArgumentError, ":end must be equal to or after :start" if options[:start] && options[:end] && (options[:start] > options[:end])
89
+
90
+ paginated_options = {
91
+ coerce_into: 'Ably::Models::PresenceMessage',
92
+ async_blocking_operations: options.delete(:async_blocking_operations),
93
+ }
94
+
95
+ response = client.get(url, options)
96
+
97
+ Ably::Models::PaginatedResult.new(response, url, client, paginated_options) do |presence_message|
98
+ presence_message.tap do |message|
99
+ decode_message message
100
+ end
101
+ end
102
+ end
103
+
104
+ private
105
+ def base_path
106
+ "/channels/#{URI.encode_www_form_component(channel.name)}/presence"
107
+ end
108
+
109
+ def decode_message(presence_message)
110
+ presence_message.decode client.encoders, channel.options
111
+ rescue Ably::Exceptions::CipherError, Ably::Exceptions::EncoderError => e
112
+ client.logger.error { "Decoding Error on presence channel '#{channel.name}', presence message client_id '#{presence_message.client_id}'. #{e.class.name}: #{e.message}" }
113
+ end
114
+ end
115
+ end
116
+ end
117
+ end
@@ -1,7 +1,7 @@
1
- require 'ably/rest/push/device_registrations'
2
- require 'ably/rest/push/channel_subscriptions'
1
+ require 'ably/pubsub/http/push/device_registrations'
2
+ require 'ably/pubsub/http/push/channel_subscriptions'
3
3
 
4
- module Ably::Rest
4
+ module Ably::PubSub::Http
5
5
  class Push
6
6
  # Class providing push notification administrative functionality
7
7
  # for registering devices and attaching to channels etc.
@@ -40,7 +40,7 @@ module Ably::Rest
40
40
 
41
41
  # Manage device registrations
42
42
  #
43
- # @return [Ably::Rest::Push::DeviceRegistrations]
43
+ # @return [Ably::PubSub::Http::Push::DeviceRegistrations]
44
44
  #
45
45
  def device_registrations
46
46
  @device_registrations ||= DeviceRegistrations.new(self)
@@ -48,7 +48,7 @@ module Ably::Rest
48
48
 
49
49
  # Manage channel subscriptions for devices or clients
50
50
  #
51
- # @return [Ably::Rest::Push::ChannelSubscriptions]
51
+ # @return [Ably::PubSub::Http::Push::ChannelSubscriptions]
52
52
  #
53
53
  def channel_subscriptions
54
54
  @channel_subscriptions ||= ChannelSubscriptions.new(self)
@@ -1,4 +1,4 @@
1
- module Ably::Rest
1
+ module Ably::PubSub::Http
2
2
  class Push
3
3
  # Manage push notification channel subscriptions for devices or client identifiers
4
4
  class ChannelSubscriptions
@@ -1,4 +1,4 @@
1
- module Ably::Rest
1
+ module Ably::PubSub::Http
2
2
  class Push
3
3
  # Manage device registrations for push notifications
4
4
  class DeviceRegistrations
@@ -0,0 +1,27 @@
1
+ require 'ably/pubsub/http/push/admin'
2
+
3
+ module Ably
4
+ module PubSub
5
+ module Http
6
+ # Class providing push notification functionality
7
+ class Push
8
+ include Ably::Modules::Conversions
9
+
10
+ # @private
11
+ attr_reader :client
12
+
13
+ def initialize(client)
14
+ @client = client
15
+ end
16
+
17
+ # Admin features for push notifications like managing devices and channel subscriptions
18
+ #
19
+ # @return [Ably::PubSub::Http::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 'ably/pubsub/http/channel'
2
+ require 'ably/pubsub/http/channels'
3
+ require 'ably/pubsub/http/client'
4
+ require 'ably/pubsub/http/push'
5
+ require 'ably/pubsub/http/presence'
6
+
7
+ require 'ably/models/message_encoders/base'
8
+
9
+ Dir.glob(File.expand_path("../models/*.rb", File.dirname(__FILE__))).each do |file|
10
+ require file
11
+ end
12
+
13
+ module Ably
14
+ module PubSub
15
+ # Http is the namespace of the stateless HTTP client and the models it returns.
16
+ #
17
+ # @example
18
+ # client = Ably::PubSub::Server.create_http_client("xxxxx")
19
+ # channel = client.channel("test")
20
+ # channel.publish "greeting", "data"
21
+ #
22
+ module Http
23
+ # Refuses construction. This was a convenience alias for the {Ably::PubSub::Http::Client}
24
+ # constructor, which no longer accepts direct construction: the package a client is
25
+ # created from is what declares the client's side to the platform, and a client
26
+ # constructed here declares none.
27
+ #
28
+ # Use {Ably::PubSub::Server.create_http_client} from the +ably-pubsub-server+ gem.
29
+ #
30
+ # @raise [Ably::Exceptions::DirectConstructionNotSupported] always
31
+ def self.new(*args, **kwargs, &block)
32
+ raise Ably::Internal.direct_construction_error(
33
+ 'Ably::PubSub::Http.new', 'Ably::PubSub::Server.create_http_client(options)'
34
+ )
35
+ end
36
+ end
37
+ end
38
+ end