Class: RComet::Channel
- Inherits:
-
Object
- Object
- RComet::Channel
- Defined in:
- lib/rcomet/channel.rb
Constant Summary collapse
- HANDSHAKE =
'/meta/handshake'- CONNECT =
'/meta/connect'- SUBSCRIBE =
'/meta/subscribe'- UNSUBSCRIBE =
'/meta/unsubscribe'- DISCONNECT =
'/meta/disconnect'
Instance Attribute Summary collapse
-
#handler ⇒ Object
readonly
Returns the value of attribute handler.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#add_user(user) ⇒ Object
:nodoc:.
-
#callback(&block) ⇒ Object
Define the channel publishion callback.
-
#data(data = nil, &block) ⇒ Object
Send data to the channel or, if no parameter is given, get available data for the channel.
-
#initialize(path, data = nil) ⇒ Channel
constructor
Create a new channel.
Constructor Details
Instance Attribute Details
#handler ⇒ Object (readonly)
Returns the value of attribute handler.
35 36 37 |
# File 'lib/rcomet/channel.rb', line 35 def handler @handler end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
35 36 37 |
# File 'lib/rcomet/channel.rb', line 35 def path @path end |
Instance Method Details
#add_user(user) ⇒ Object
:nodoc:
72 73 74 |
# File 'lib/rcomet/channel.rb', line 72 def add_user( user ) #:nodoc: @users[user.id] = user end |
#callback(&block) ⇒ Object
Define the channel publishion callback
68 69 70 |
# File 'lib/rcomet/channel.rb', line 68 def callback( &block ) @handler = block end |
#data(data = nil, &block) ⇒ Object
Send data to the channel or, if no parameter is given, get available data for the channel
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/rcomet/channel.rb', line 46 def data( data = nil, &block ) unless data or block_given? return @data end if block_given? @data = yield( data ) else @data = data end @users.each do |id, user| = { 'channel' => @path, 'data' => @data, 'clientId' => id } user.send( ) end end |