Module: Faye

Defined in:
lib/faye.rb,
lib/faye/error.rb,
lib/faye/engines/proxy.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/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/protocol/publication.rb,
lib/faye/transport/web_socket.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, Publication, RackAdapter, Server, Subscription, Transport

Constant Summary collapse

VERSION =
'0.8.0'
ROOT =
File.expand_path(File.dirname(__FILE__))
BAYEUX_VERSION =
'1.0'
JSONP_CALLBACK =
'jsonpcallback'
CONNECTION_TYPES =
%w[long-polling cross-origin-long-polling callback-polling websocket eventsource 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.



48
49
50
# File 'lib/faye.rb', line 48

def logger
  @logger
end

Class Method Details

.async_each(list, iterator, callback) ⇒ Object



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/faye.rb', line 83

def self.async_each(list, iterator, callback)
  n       = list.size
  i       = -1
  calls   = 0
  looping = false
  
  loop, resume = nil, nil
  
  iterate = lambda do
    calls -= 1
    i += 1
    if i == n
      callback.call if callback
    else
      iterator.call(list[i], resume)
    end
  end
  
  loop = lambda do
    unless looping
      looping = true
      iterate.call while calls > 0
      looping = false
    end
  end
  
  resume = lambda do
    calls += 1
    loop.call
  end
  resume.call
end

.copy_object(object) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/faye.rb', line 60

def self.copy_object(object)
  case object
  when Hash
    clone = {}
    object.each { |k,v| clone[k] = copy_object(v) }
    clone
  when Array
    clone = []
    object.each { |v| clone << copy_object(v) }
    clone
  else
    object
  end
end

.ensure_reactor_running!Object



52
53
54
# File 'lib/faye.rb', line 52

def self.ensure_reactor_running!
  Engine.ensure_reactor_running!
end

.random(*args) ⇒ Object



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

def self.random(*args)
  Engine.random(*args)
end

.to_json(value) ⇒ Object



75
76
77
78
79
80
81
# File 'lib/faye.rb', line 75

def self.to_json(value)
  case value
    when Hash, Array then Yajl::Encoder.encode(value)
    when String, NilClass then value.inspect
    else value.to_s
  end
end