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/mixins/deferrable.rb,
lib/faye/engines/connection.rb,
lib/faye/protocol/scheduler.rb,
lib/faye/protocol/dispatcher.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: Deferrable, Engine, Extensible, Grammar, Logging, Publisher, Timeouts Classes: Channel, Client, Dispatcher, Error, Namespace, Publication, RackAdapter, Scheduler, Server, StaticServer, Subscription, Transport

Constant Summary collapse

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



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

def logger
  @logger
end

Class Method Details

.async_each(list, iterator, callback) ⇒ Object



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
121
122
123
124
125
126
127
# File 'lib/faye.rb', line 96

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



64
65
66
67
# File 'lib/faye.rb', line 64

def self.client_id_from_messages(messages)
  first = [messages].flatten.find { |m| m['channel'] == '/meta/connect' }
  first && first['clientId']
end

.copy_object(object) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/faye.rb', line 69

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



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

def self.ensure_reactor_running!
  Engine.ensure_reactor_running!
end

.parse_url(url) ⇒ Object



84
85
86
# File 'lib/faye.rb', line 84

def self.parse_url(url)
  String === url ? URI.parse(url) : url
end

.random(*args) ⇒ Object



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

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

.to_json(value) ⇒ Object



88
89
90
91
92
93
94
# File 'lib/faye.rb', line 88

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