Module: Ably::Realtime

Defined in:
lib/ably/realtime.rb,
lib/ably/realtime/auth.rb,
lib/ably/realtime/push.rb,
lib/ably/realtime/client.rb,
lib/ably/realtime/channel.rb,
lib/ably/realtime/channels.rb,
lib/ably/realtime/presence.rb,
lib/ably/realtime/connection.rb,
lib/ably/realtime/push/admin.rb,
lib/ably/realtime/channel/publisher.rb,
lib/ably/realtime/channel/push_channel.rb,
lib/ably/realtime/presence/members_map.rb,
lib/ably/realtime/channel/channel_manager.rb,
lib/ably/realtime/presence/presence_manager.rb,
lib/ably/realtime/push/device_registrations.rb,
lib/ably/realtime/channel/channel_properties.rb,
lib/ably/realtime/push/channel_subscriptions.rb,
lib/ably/realtime/channel/channel_state_machine.rb,
lib/ably/realtime/connection/connection_manager.rb,
lib/ably/realtime/connection/websocket_transport.rb,
lib/ably/realtime/presence/presence_state_machine.rb,
lib/ably/realtime/client/incoming_message_dispatcher.rb,
lib/ably/realtime/client/outgoing_message_dispatcher.rb,
lib/ably/realtime/connection/connection_state_machine.rb

Overview

Realtime provides the top-level class to be instanced for the Ably Realtime library

Examples:

client = Ably::Realtime.new("xxxxx")
channel = client.channel("test")
channel.subscribe do |message|
  message[:name] #=> "greeting"
end
channel.publish "greeting", "data"

Defined Under Namespace

Modules: Models Classes: Auth, Channel, Channels, Client, Connection, Presence, Push

Class Method Summary collapse

Class Method Details

.new(options) ⇒ Ably::Realtime::Client

Convenience method providing an alias to Client constructor.

Examples:

# create a new client authenticating with basic auth
client = Ably::Realtime.new('key.id:secret')

# create a new client authenticating with basic auth and a client_id
client = Ably::Realtime.new(key: 'key.id:secret', client_id: 'john')

Parameters:

  • options (Hash)

    a customizable set of options

Options Hash (options):

  • (see (Object)

    Ably::Rest::Client#initialize) An options Hash object.

  • :auth_callback (Proc)

    when provided, the Proc will be called with the token params hash as the first argument, whenever a new token is required. Whilst the proc is called synchronously, it does not block the EventMachine reactor as it is run in a separate thread. The Proc should return a token string, Models::TokenDetails or JSON equivalent, Models::TokenRequest or JSON equivalent

  • :queue_messages (Boolean)

    If false, this disables the default behaviour whereby the library queues messages on a connection in the disconnected or connecting states

  • :echo_messages (Boolean)

    If false, prevents messages originating from this connection being echoed back on the same connection

  • :recover (String)

    When a recover option is specified a connection inherits the state of a previous connection that may have existed under a different instance of the Realtime library, please refer to the API documentation for further information on connection state recovery

  • :auto_connect (Boolean)

    By default as soon as the client library is instantiated it will connect to Ably. You can optionally set this to false and explicitly connect.

  • :transport_params (Hash)

    Additional parameters to be sent in the querystring when initiating a realtime connection. Keys are Strings, values are Stringifiable(a value must respond to #to_s)

  • :channel_retry_timeout (Integer) — default: 15 seconds

    . When a channel becomes SUSPENDED, after this delay in seconds, the channel will automatically attempt to reattach if the connection is CONNECTED

  • :disconnected_retry_timeout (Integer) — default: 15 seconds

    . When the connection enters the DISCONNECTED state, after this delay in seconds, if the state is still DISCONNECTED, the client library will attempt to reconnect automatically

  • :suspended_retry_timeout (Integer) — default: 30 seconds

    . When the connection enters the SUSPENDED state, after this delay in seconds, if the state is still SUSPENDED, the client library will attempt to reconnect automatically

  • :disable_websocket_heartbeats (Boolean)

    WebSocket heartbeats are more efficient than protocol level heartbeats, however they can be disabled for development purposes

Returns:



56
57
58
# File 'lib/ably/realtime.rb', line 56

def self.new(options)
  Ably::Realtime::Client.new(options)
end