Class: Rocket::Channel

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, channel) ⇒ Channel

Returns a new instance of Channel.



9
10
11
12
# File 'lib/rocket/channel.rb', line 9

def initialize(client, channel)
  @client  = client
  @channel = channel
end

Instance Attribute Details

#channelObject (readonly)

Returns the value of attribute channel.



7
8
9
# File 'lib/rocket/channel.rb', line 7

def channel
  @channel
end

#clientObject (readonly)

Returns the value of attribute client.



6
7
8
# File 'lib/rocket/channel.rb', line 6

def client
  @client
end

Instance Method Details

#trigger(event, data) ⇒ Object



14
15
16
17
18
# File 'lib/rocket/channel.rb', line 14

def trigger(event, data)
  client.connection do |socket|
    socket.send({ :event => event, :channel => channel, :data => data }.to_json)
  end
end