Class: Bayeux::Client
- Inherits:
-
Object
- Object
- Bayeux::Client
- Defined in:
- lib/bayeux.rb
Overview
A connected client
Instance Attribute Summary collapse
-
#channel ⇒ Object
The EM::Channel on which this client subscribes.
-
#channels ⇒ Object
Array of channels this client is subscribed to.
-
#clientId ⇒ Object
The clientId we assigned.
-
#queue ⇒ Object
Messages queued for this client (an Array).
-
#subscription ⇒ Object
The EM::Subscription a long-poll is currently active.
Instance Method Summary collapse
-
#flush(sinatra) ⇒ Object
:nodoc:.
-
#initialize(clientId) ⇒ Client
constructor
:nodoc:.
Constructor Details
#initialize(clientId) ⇒ Client
:nodoc:
40 41 42 43 44 45 |
# File 'lib/bayeux.rb', line 40 def initialize clientId #:nodoc: @clientId = clientId @channel = EM::Channel.new @queue = [] @channels = [] end |
Instance Attribute Details
#channel ⇒ Object
The EM::Channel on which this client subscribes
29 30 31 |
# File 'lib/bayeux.rb', line 29 def channel @channel end |
#channels ⇒ Object
Array of channels this client is subscribed to
38 39 40 |
# File 'lib/bayeux.rb', line 38 def channels @channels end |
#clientId ⇒ Object
The clientId we assigned
23 24 25 |
# File 'lib/bayeux.rb', line 23 def clientId @clientId end |
#queue ⇒ Object
Messages queued for this client (an Array)
35 36 37 |
# File 'lib/bayeux.rb', line 35 def queue @queue end |
#subscription ⇒ Object
The EM::Subscription a long-poll is currently active
32 33 34 |
# File 'lib/bayeux.rb', line 32 def subscription @subscription end |
Instance Method Details
#flush(sinatra) ⇒ Object
:nodoc:
47 48 49 50 51 52 53 |
# File 'lib/bayeux.rb', line 47 def flush sinatra #:nodoc: queued = @queue sinatra.trace "Sending to #{@clientId}: #{queued.inspect}" @queue = [] sinatra.respond(queued) end |