Class: Faye::Server
- Inherits:
-
Object
- Object
- Faye::Server
- Includes:
- Extensible, Logging
- Defined in:
- lib/faye/protocol/server.rb
Constant Summary
Constants included from Logging
Logging::DEFAULT_LOG_LEVEL, Logging::LOG_LEVELS
Instance Attribute Summary
Attributes included from Logging
Instance Method Summary collapse
- #client_ids ⇒ Object
- #flush_connection(messages) ⇒ Object
-
#initialize(options = {}) ⇒ Server
constructor
A new instance of Server.
- #process(messages, local_or_remote = false, &callback) ⇒ Object
Methods included from Extensible
#add_extension, #pipe_through_extensions, #remove_extension
Methods included from Logging
Constructor Details
Instance Method Details
#client_ids ⇒ Object
15 16 17 |
# File 'lib/faye/protocol/server.rb', line 15 def client_ids @connections.keys end |
#flush_connection(messages) ⇒ Object
54 55 56 57 58 59 |
# File 'lib/faye/protocol/server.rb', line 54 def flush_connection() [].flatten.each do || connection = @connections[['clientId']] connection.flush! if connection end end |
#process(messages, local_or_remote = false, &callback) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/faye/protocol/server.rb', line 19 def process(, local_or_remote = false, &callback) socket = local_or_remote.is_a?(WebSocket) ? local_or_remote : nil local = (local_or_remote == true) debug('Processing messages from ? client', local ? 'LOCAL' : 'REMOTE') = [].flatten processed, responses = 0, [] gather_replies = lambda do |replies| responses.concat(replies) processed += 1 callback.call(responses.compact) if processed == .size end handle_reply = lambda do |replies| extended, expected = 0, replies.size gather_replies.call(replies) if expected == 0 replies.each_with_index do |reply, i| pipe_through_extensions(:outgoing, reply) do || replies[i] = extended += 1 gather_replies.call(replies) if extended == expected end end end .each do || pipe_through_extensions(:incoming, ) do || handle(, socket, local, &handle_reply) end end end |