Class: FrCable::Channel::Base

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(_params) ⇒ Base

Returns a new instance of Base.



15
16
17
18
# File 'lib/fr_cable/channel/base.rb', line 15

def initialize _params
  @params = _params
  @broadcasted_room = nil
end

Instance Attribute Details

#broadcasted_roomObject (readonly)

Returns the value of attribute broadcasted_room.



5
6
7
# File 'lib/fr_cable/channel/base.rb', line 5

def broadcasted_room
  @broadcasted_room
end

#paramsObject (readonly)

Returns the value of attribute params.



5
6
7
# File 'lib/fr_cable/channel/base.rb', line 5

def params
  @params
end

Class Method Details

.broadcast(room, message) ⇒ Object



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

def self.broadcast(room, message)
  ::FrCable::HTTPClient.post(::FrCable::Rack.config[:socket_server_url], body: {type: "message", payload: {room: room, message: message}}.to_json)
end

Instance Method Details

#broadcast(room, message) ⇒ Object



11
12
13
# File 'lib/fr_cable/channel/base.rb', line 11

def broadcast(room, message)
  ::FrCable::Channel::Base.broadcast("#{self.class.name}:#{room}", message)
end

#receive(message) ⇒ Object



20
21
22
# File 'lib/fr_cable/channel/base.rb', line 20

def receive message
  # void
end

#subscribed(connection_uuid) ⇒ Object



24
25
26
# File 'lib/fr_cable/channel/base.rb', line 24

def subscribed connection_uuid
  true
end

#unsubscribedObject



28
29
30
# File 'lib/fr_cable/channel/base.rb', line 28

def unsubscribed
  # void
end