lib/ably/realtime/channel.rb in ably-0.2.0 vs lib/ably/realtime/channel.rb in ably-0.6.2

- old
+ new

@@ -34,10 +34,11 @@ # class Channel include Ably::Modules::Conversions include Ably::Modules::EventEmitter include Ably::Modules::EventMachineHelpers + include Ably::Modules::AsyncWrapper extend Ably::Modules::Enum STATE = ruby_enum('STATE', :initialized, :attaching, @@ -100,20 +101,24 @@ # Subscribe to messages matching providing event name, or all messages if event name not provided # # @param name [String] The event name of the message to subscribe to if provided. Defaults to all events. # @yield [Ably::Models::Message] For each message received, the block is called # + # @return [void] + # def subscribe(name = :all, &blk) attach unless attached? || attaching? subscriptions[message_name_key(name)] << blk end # Unsubscribe the matching block for messages matching providing event name, or all messages if event name not provided. # If a block is not provided, all subscriptions will be unsubscribed # # @param name [String] The event name of the message to subscribe to if provided. Defaults to all events. # + # @return [void] + # def unsubscribe(name = :all, &blk) if message_name_key(name) == :all subscriptions.keys else Array(message_name_key(name)) @@ -172,11 +177,17 @@ # Return the message history of the channel # # @param (see Ably::Rest::Channel#history) # @option options (see Ably::Rest::Channel#history) - def history(options = {}) - rest_channel.history(options) + # + # @yield [Ably::Models::PaginatedResource<Ably::Models::Message>] An Array of {Ably::Models::Message} objects that supports paging (#next_page, #first_page) + # + # @return [EventMachine::Deferrable] + def history(options = {}, &callback) + async_wrap(callback) do + rest_channel.history(options.merge(async_blocking_operations: true)) + end end # @!attribute [r] __incoming_msgbus__ # @return [Ably::Util::PubSub] Client library internal channel incoming message bus # @api private