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/protocol/socket.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,
lib/faye/adapters/static_server.rb

Defined Under Namespace

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

Constant Summary collapse

VERSION =
'0.8.9'
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.



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

def logger
  @logger
end

Class Method Details

.async_each(list, iterator, callback) ⇒ Object



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
115
116
117
118
119
120
# File 'lib/faye.rb', line 89

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

.client_id_from_messages(messages) ⇒ Object



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

def self.client_id_from_messages(messages)
  first = [messages].flatten.first
  first && first['clientId']
end

.copy_object(object) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/faye.rb', line 66

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



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

def self.ensure_reactor_running!
  Engine.ensure_reactor_running!
end

.random(*args) ⇒ Object



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

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

.to_json(value) ⇒ Object



81
82
83
84
85
86
87
# File 'lib/faye.rb', line 81

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