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.



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

def initialize(socket)
  @socket = socket
end

Instance Attribute Details

#socketObject (readonly)

Returns the value of attribute socket.



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

def socket
  @socket
end

Instance Method Details

#add(channel_id, broadcasting) ⇒ Object

Start streaming from broadcasting to the channel.



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

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

#remove(channel_id, broadcasting) ⇒ Object

Stop streaming from broadcasting to the channel.



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

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

#remove_all(channel_id) ⇒ Object

Stop all streams for the channel



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

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