Module: Faye

Defined in:
lib/faye.rb,
lib/faye/error.rb,
lib/faye/engines/base.rb,
lib/faye/engines/redis.rb,
lib/faye/engines/memory.rb,
lib/faye/mixins/logging.rb,
lib/faye/transport/http.rb,
lib/faye/util/namespace.rb,
lib/faye/mixins/timeouts.rb,
lib/faye/protocol/client.rb,
lib/faye/protocol/server.rb,
lib/faye/transport/local.rb,
lib/faye/util/web_socket.rb,
lib/faye/mixins/publisher.rb,
lib/faye/protocol/channel.rb,
lib/faye/protocol/grammar.rb,
lib/faye/engines/connection.rb,
lib/faye/protocol/extensible.rb,
lib/faye/transport/transport.rb,
lib/faye/adapters/rack_adapter.rb,
lib/faye/protocol/subscription.rb

Defined Under Namespace

Modules: Engine, Extensible, Grammar, Logging, Publisher, Timeouts Classes: Channel, Client, Error, Namespace, RackAdapter, Server, Subscription, Transport, WebSocket

Constant Summary collapse

VERSION =
'0.6.1'
ROOT =
File.expand_path(File.dirname(__FILE__))
BAYEUX_VERSION =
'1.0'
ID_LENGTH =
128
JSONP_CALLBACK =
'jsonpcallback'
CONNECTION_TYPES =
%w[long-polling cross-origin-long-polling callback-polling websocket in-process]
MANDATORY_CONNECTION_TYPES =
%w[long-polling callback-polling in-process]

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.loggerObject

Returns the value of attribute logger.



4
5
6
# File 'lib/faye/mixins/logging.rb', line 4

def logger
  @logger
end

Class Method Details

.ensure_reactor_running!Object



61
62
63
64
# File 'lib/faye.rb', line 61

def self.ensure_reactor_running!
  Thread.new { EM.run } unless EM.reactor_running?
  while not EM.reactor_running?; end
end

.random(bitlength = ID_LENGTH) ⇒ Object



45
46
47
48
49
50
51
# File 'lib/faye.rb', line 45

def self.random(bitlength = ID_LENGTH)
  limit    = 2 ** bitlength - 1
  max_size = limit.to_s(36).size
  string   = rand(limit).to_s(36)
  string = '0' + string while string.size < max_size
  string
end

.to_json(value) ⇒ Object



53
54
55
56
57
58
59
# File 'lib/faye.rb', line 53

def self.to_json(value)
  case value
    when Hash, Array then JSON.unparse(value)
    when String, NilClass then value.inspect
    else value.to_s
  end
end