Class: LiteCable::Connection::Streams

Inherits:
Object
  • Object
show all
Defined in:
lib/lite_cable/connection/streams.rb

Overview

Manage the connection streams

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(socket) ⇒ Streams

Returns a new instance of Streams.



8
9
10
# File 'lib/lite_cable/connection/streams.rb', line 8

def initialize(socket)
  @socket = socket
end

Instance Attribute Details

#socketObject (readonly)

Returns the value of attribute socket.



6
7
8
# File 'lib/lite_cable/connection/streams.rb', line 6

def socket
  @socket
end

Instance Method Details

#add(channel_id, broadcasting) ⇒ Object

Start streaming from broadcasting to the channel.



13
14
15
# File 'lib/lite_cable/connection/streams.rb', line 13

def add(channel_id, broadcasting)
  socket.subscribe(channel_id, broadcasting)
end

#remove(channel_id, broadcasting) ⇒ Object

Stop streaming from broadcasting to the channel.



18
19
20
# File 'lib/lite_cable/connection/streams.rb', line 18

def remove(channel_id, broadcasting)
  socket.unsubscribe(channel_id, broadcasting)
end

#remove_all(channel_id) ⇒ Object

Stop all streams for the channel



23
24
25
# File 'lib/lite_cable/connection/streams.rb', line 23

def remove_all(channel_id)
  socket.unsubscribe_from_all(channel_id)
end