Class: Glib::Channel::AppearanceChannel

Inherits:
ApplicationCable::Channel
  • Object
show all
Defined in:
app/channels/glib/channel/appearance_channel.rb

Instance Method Summary collapse

Instance Method Details

#status(data) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/channels/glib/channel/appearance_channel.rb', line 8

def status(data)
  action = {
    action: 'labels/set',
    targetId: 'label-1',
    text: data['text'],
    onSet: {
      action: 'timeouts/set',
      interval: 3000,
      timerId: 'label-1-set',
      onTimeout: {
        action: 'labels/set',
        targetId: 'label-1',
        text: "Room ##{data['room'].upcase}"
      }
    }
  }

  broadcast_to("appearance_#{data['room']}", action)
end

#subscribedObject



4
5
6
# File 'app/channels/glib/channel/appearance_channel.rb', line 4

def subscribed
  stream_for "appearance_#{params[:room]}"
end