Class: Bayeux::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/bayeux.rb

Overview

A connected client

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#channelObject

The EM::Channel on which this client subscribes



29
30
31
# File 'lib/bayeux.rb', line 29

def channel
  @channel
end

#channelsObject

Array of channels this client is subscribed to



38
39
40
# File 'lib/bayeux.rb', line 38

def channels
  @channels
end

#clientIdObject

The clientId we assigned



23
24
25
# File 'lib/bayeux.rb', line 23

def clientId
  @clientId
end

#queueObject

Messages queued for this client (an Array)



35
36
37
# File 'lib/bayeux.rb', line 35

def queue
  @queue
end

#subscriptionObject

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