Module: Ably::Realtime

Defined in:
lib/ably/realtime.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/presence/members_map.rb,
lib/ably/realtime/channel/channel_manager.rb,
lib/ably/realtime/presence/presence_manager.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: Channel, Channels, Client, Connection, Presence

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')

Options Hash (options):

  • :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.

  • :tls (Boolean)

    TLS is used by default, providing a value of false disables TLS. Please note Basic Auth is disallowed without TLS as secrets cannot be transmitted over unsecured connections.

  • :key (String)

    API key comprising the key name and key secret in a single string

  • :token (String)

    Token string or Models::TokenDetails used to authenticate requests

  • :token_details (String)

    Models::TokenDetails used to authenticate requests

  • :use_token_auth (Boolean)

    Will force Basic Auth if set to false, and Token auth if set to true

  • :environment (String)

    Specify ‘sandbox’ when testing the client library against an alternate Ably environment

  • :protocol (Symbol)

    Protocol used to communicate with Ably, :json and :msgpack currently supported. Defaults to :msgpack

  • :use_binary_protocol (Boolean)

    Protocol used to communicate with Ably, defaults to true and uses MessagePack protocol. This option will overide :protocol option

  • :log_level (Logger::Severity, Symbol)

    Log level for the standard Logger that outputs to STDOUT. Defaults to Logger::ERROR, can be set to :fatal (Logger::FATAL), :error (Logger::ERROR), :warn (Logger::WARN), :info (Logger::INFO), :debug (Logger::DEBUG) or :none

  • :logger (Logger)

    A custom logger can be used however it must adhere to the Ruby Logger interface, see www.ruby-doc.org/stdlib-1.9.3/libdoc/logger/rdoc/Logger.html

  • :key (String)

    API key comprising the key name and key secret in a single string

  • :force (Boolean)

    obtains a new token even if the current token is valid

  • :key (String)

    complete API key for the designated application

  • :client_id (String)

    client ID identifying this connection to other clients (defaults to client client_id if configured)

  • :auth_url (String)

    a URL to be used to GET or POST a set of token request params, to obtain a signed token request.

  • :auth_headers (Hash)

    a set of application-specific headers to be added to any request made to the authUrl

  • :auth_params (Hash)

    a set of application-specific query params to be added to any request made to the authUrl

  • :auth_method (Symbol)

    HTTP method to use with auth_url, must be either :get or :post (defaults to :get)

  • :auth_callback (Proc)

    this Proc / block will be called with the Auth#auth_options Hash as the first argument whenever a new token is required. The Proc should return a token string, Models::TokenDetails or JSON equivalent, Models::TokenRequest or JSON equivalent

  • :ttl (Integer)

    validity time in seconds for the requested Models::TokenDetails. Limits may apply, see https://www.ably.io/documentation/other/authentication

  • :capability (Hash)

    canonicalised representation of the resource paths and associated operations

  • :query_time (Boolean)

    when true will query the Ably system for the current time instead of using the local time

  • :timestamp (Time)

    the time of the of the request

  • :nonce (String)

    an unquoted, unescaped random string of at least 16 characters



51
52
53
# File 'lib/ably/realtime.rb', line 51

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